// for PCRaw start.
bool isIndexTxt(ChanInfo *info)
{
- int len;
+ size_t len;
if( info &&
info->contentType == ChanInfo::T_RAW &&
mount.clear();
bump = false;
stayConnected = false;
+ stealth = false; //JP-MOD
+ overrideMaxRelaysPerChannel = -1; //JP-MOD
+ bClap = false; //JP-MOD
icyMetaInterval = 0;
streamPos = 0;
return tot;
}
-
-
+// -----------------------------------
+int Channel::totalClaps() //JP-MOD
+{
+ ChanHitList *chl = chanMgr->findHitListByID(info.id);
+ return chl ? chl->numClaps() : 0;
+}
// -----------------------------------
void Channel::startGet()
if (!chl)
throw StreamException("Broadcast channel has no hitlist");
- int numListeners = totalListeners();
- int numRelays = totalRelays();
+ int numListeners = stealth ? -1 : totalListeners(); //JP-MOD \83\8a\83X\83i\81[\90\94\89B\95Á\8b@\94\
+ int numRelays = stealth ? -1 : totalRelays(); //JP-MOD \83\8a\83\8c\81[\90\94\89B\95Á\8b@\94\
unsigned int oldp = rawData.getOldestPos();
unsigned int newp = rawData.getLatestPos();
hit.initLocal(numListeners,numRelays,info.numSkips,info.getUptime(),isPlaying(), false, 0, this, oldp,newp);
hit.tracker = true;
-#ifndef VERSION_EX
- atom.writeParent(PCP_BCST,8);
-#else
- atom.writeParent(PCP_BCST,10);
-#endif
- atom.writeChar(PCP_BCST_GROUP,PCP_BCST_GROUP_ROOT);
- atom.writeChar(PCP_BCST_HOPS,0);
- atom.writeChar(PCP_BCST_TTL,11);
- atom.writeBytes(PCP_BCST_FROM,servMgr->sessionID.id,16);
- atom.writeInt(PCP_BCST_VERSION,PCP_CLIENT_VERSION);
- atom.writeInt(PCP_BCST_VERSION_VP,PCP_CLIENT_VERSION_VP);
-#ifdef VERSION_EX
+ if (version_ex == 0)
+ {
+ atom.writeParent(PCP_BCST,8);
+ } else
+ {
+ atom.writeParent(PCP_BCST,10);
+ }
+ atom.writeChar(PCP_BCST_GROUP,PCP_BCST_GROUP_ROOT);
+ atom.writeChar(PCP_BCST_HOPS,0);
+ atom.writeChar(PCP_BCST_TTL,11);
+ atom.writeBytes(PCP_BCST_FROM,servMgr->sessionID.id,16);
+ atom.writeInt(PCP_BCST_VERSION,PCP_CLIENT_VERSION);
+ atom.writeInt(PCP_BCST_VERSION_VP,PCP_CLIENT_VERSION_VP);
+
+ if (version_ex)
+ {
atom.writeBytes(PCP_BCST_VERSION_EX_PREFIX,PCP_CLIENT_VERSION_EX_PREFIX,2);
atom.writeShort(PCP_BCST_VERSION_EX_NUMBER,PCP_CLIENT_VERSION_EX_NUMBER);
-#endif
- atom.writeParent(PCP_CHAN,4);
- atom.writeBytes(PCP_CHAN_ID,info.id.id,16);
- atom.writeBytes(PCP_CHAN_BCID,chanMgr->broadcastID.id,16);
- info.writeInfoAtoms(atom);
- info.writeTrackAtoms(atom);
- hit.writeAtoms(atom,info.id);
+ }
+ atom.writeParent(PCP_CHAN,4);
+ atom.writeBytes(PCP_CHAN_ID,info.id.id,16);
+ atom.writeBytes(PCP_CHAN_BCID,chanMgr->broadcastID.id,16);
+ info.writeInfoAtoms(atom);
+ info.writeTrackAtoms(atom);
+ hit.writeAtoms(atom,info.id);
pack.len = mem.pos;
AtomStream atom(mem);
-#ifndef VERSION_EX
- atom.writeParent(PCP_BCST,8);
-#else
- atom.writeParent(PCP_BCST,10);
-#endif
- atom.writeChar(PCP_BCST_HOPS,0);
- atom.writeChar(PCP_BCST_TTL,7);
- atom.writeChar(PCP_BCST_GROUP,PCP_BCST_GROUP_RELAYS);
- atom.writeBytes(PCP_BCST_FROM,servMgr->sessionID.id,16);
- atom.writeInt(PCP_BCST_VERSION,PCP_CLIENT_VERSION);
- atom.writeInt(PCP_BCST_VERSION_VP,PCP_CLIENT_VERSION_VP);
-#ifdef VERSION_EX
+ if (version_ex == 0)
+ {
+ atom.writeParent(PCP_BCST,8);
+ } else
+ {
+ atom.writeParent(PCP_BCST,10);
+ }
+ atom.writeChar(PCP_BCST_HOPS,0);
+ atom.writeChar(PCP_BCST_TTL,7);
+ atom.writeChar(PCP_BCST_GROUP,PCP_BCST_GROUP_RELAYS);
+ atom.writeBytes(PCP_BCST_FROM,servMgr->sessionID.id,16);
+ atom.writeInt(PCP_BCST_VERSION,PCP_CLIENT_VERSION);
+ atom.writeInt(PCP_BCST_VERSION_VP,PCP_CLIENT_VERSION_VP);
+ if (version_ex)
+ {
atom.writeBytes(PCP_BCST_VERSION_EX_PREFIX,PCP_CLIENT_VERSION_EX_PREFIX,2);
atom.writeShort(PCP_BCST_VERSION_EX_NUMBER,PCP_CLIENT_VERSION_EX_NUMBER);
-#endif
- atom.writeBytes(PCP_BCST_CHANID,info.id.id,16);
- atom.writeParent(PCP_CHAN,3);
- atom.writeBytes(PCP_CHAN_ID,info.id.id,16);
- info.writeInfoAtoms(atom);
- info.writeTrackAtoms(atom);
+ }
+ atom.writeBytes(PCP_BCST_CHANID,info.id.id,16);
+ atom.writeParent(PCP_CHAN,3);
+ atom.writeBytes(PCP_CHAN_ID,info.id.id,16);
+ info.writeInfoAtoms(atom);
+ info.writeTrackAtoms(atom);
pack.len = mem.pos;
pack.type = ChanPacket::T_PCP;
// LOG_DEBUG("isPlaying-------------------------------------- %d %d", ch->isPlaying(), isPlaying);
hit.initLocal(newLocalListeners,newLocalRelays,ch->info.numSkips,ch->info.getUptime(),ch->isPlaying(), ch->isFull(), ch->info.bitrate, ch, oldp, newp);
+ { //JP-MOD
+ if(!(ch->info.ppFlags & ServMgr::bcstClap))
+ ch->bClap = false;
+ hit.initLocal_pp(ch->stealth, ch->bClap ? 1 : 0);
+ }
hit.tracker = ch->isBroadcasting();
if ( (((ctime-lastUpdate)>chanMgr->hostUpdateInterval) && chanMgr->hostUpdateInterval)
|| (ch->chDisp.relay != hit.relay)
|| (ch->chDisp.relayfull != hit.relayfull)
|| (ch->chDisp.chfull != hit.chfull)
- || (ch->chDisp.ratefull != hit.ratefull)
+ || (ch->chDisp.ratefull != hit.ratefull)
+ || (ch->bClap && ((ctime-lastClapped) > 60)) //JP-MOD
){
numListeners = newLocalListeners;
numRelays = newLocalRelays;
isPlaying = ch->isPlaying();
fwState = servMgr->getFirewall();
lastUpdate = ctime;
+
+ if(ch->bClap){ //JP-MOD
+ lastClapped = ctime;
+ ch->bClap = false;
+ }
ch->chDisp = hit;
GnuID noID;
noID.clear();
-#ifndef VERSION_EX
+ if (version_ex == 0)
+ {
atom.writeParent(PCP_BCST,8);
-#else
+ } else
+ {
atom.writeParent(PCP_BCST,10);
-#endif
- atom.writeChar(PCP_BCST_GROUP,PCP_BCST_GROUP_TRACKERS);
- atom.writeChar(PCP_BCST_HOPS,0);
- atom.writeChar(PCP_BCST_TTL,11);
- atom.writeBytes(PCP_BCST_FROM,servMgr->sessionID.id,16);
- atom.writeInt(PCP_BCST_VERSION,PCP_CLIENT_VERSION);
- atom.writeInt(PCP_BCST_VERSION_VP,PCP_CLIENT_VERSION_VP);
-#ifdef VERSION_EX
+ }
+ atom.writeChar(PCP_BCST_GROUP,PCP_BCST_GROUP_TRACKERS);
+ atom.writeChar(PCP_BCST_HOPS,0);
+ atom.writeChar(PCP_BCST_TTL,11);
+ atom.writeBytes(PCP_BCST_FROM,servMgr->sessionID.id,16);
+ atom.writeInt(PCP_BCST_VERSION,PCP_CLIENT_VERSION);
+ atom.writeInt(PCP_BCST_VERSION_VP,PCP_CLIENT_VERSION_VP);
+ if (version_ex)
+ {
atom.writeBytes(PCP_BCST_VERSION_EX_PREFIX,PCP_CLIENT_VERSION_EX_PREFIX,2);
atom.writeShort(PCP_BCST_VERSION_EX_NUMBER,PCP_CLIENT_VERSION_EX_NUMBER);
-#endif
- atom.writeBytes(PCP_BCST_CHANID,ch->info.id.id,16);
- hit.writeAtoms(atom,noID);
+ }
+ atom.writeBytes(PCP_BCST_CHANID,ch->info.id.id,16);
+ hit.writeAtoms(atom,noID);
pack.len = pmem.pos;
pack.type = ChanPacket::T_PCP;
else if (var == "numChannels")
sprintf(buf,"%d",numChannels());
else if (var == "djMessage")
- strcpy(buf,broadcastMsg.cstr());
+ {
+ String utf8 = broadcastMsg;
+ utf8.convertTo(String::T_UNICODESAFE);
+ strcpy(buf,utf8.cstr());
+ }
else if (var == "icyMetaInterval")
sprintf(buf,"%d",icyMetaInterval);
else if (var == "maxRelaysPerChannel")
utf8 = info.comment;
utf8.convertTo(String::T_UNICODESAFE);
strcpy(buf,utf8.cstr());
+ }else if (var == "bcstClap") //JP-MOD
+ {
+ strcpy(buf,info.ppFlags & ServMgr::bcstClap ? "1":"0");
}else if (var == "uptime")
{
String uptime;
sprintf(buf,"%d",totalRelays());
else if (var == "totalListeners")
sprintf(buf,"%d",totalListeners());
-
+ else if (var == "totalClaps") //JP-MOD
+ sprintf(buf,"%d",totalClaps());
else if (var == "status")
sprintf(buf,"%s",getStatusStr());
else if (var == "keep")
numListeners = 0;
numRelays = 0;
+ clap_pp = 0; //JP-MOD
dead = tracker = firewalled = stable = yp = false;
recv = cin = direct = relay = true;
version = PCP_CLIENT_VERSION;
version_vp = PCP_CLIENT_VERSION_VP;
-#ifdef VERSION_EX
- strncpy(version_ex_prefix, PCP_CLIENT_VERSION_EX_PREFIX,2);
- version_ex_number = PCP_CLIENT_VERSION_EX_NUMBER;
-#else
- version_ex_prefix[0] = ' ';
- version_ex_prefix[1] = ' ';
- version_ex_number = 0;
-#endif
+ if (version_ex)
+ {
+ strncpy(version_ex_prefix, PCP_CLIENT_VERSION_EX_PREFIX,2);
+ version_ex_number = PCP_CLIENT_VERSION_EX_NUMBER;
+ } else
+ {
+ version_ex_prefix[0] = ' ';
+ version_ex_prefix[1] = ' ';
+ version_ex_number = 0;
+ }
status = ch->status;
}
// -----------------------------------
+void ChanHit::initLocal_pp(bool isStealth, int numClaps) //JP-MOD
+{
+ numListeners = numListeners && !isStealth ? 1 : 0;
+ clap_pp = numClaps;
+}
+
+// -----------------------------------
void ChanHit::writeAtoms(AtomStream &atom,GnuID &chanID)
{
bool addChan=chanID.isSet();
if (tracker) fl1 |= PCP_HOST_FLAGS1_TRACKER;
if (firewalled) fl1 |= PCP_HOST_FLAGS1_PUSH;
- atom.writeParent(PCP_HOST,13 + (addChan?1:0) + (uphostdata?3:0) + (version_ex_number?2:0));
-
- if (addChan)
- atom.writeBytes(PCP_HOST_CHANID,chanID.id,16);
- atom.writeBytes(PCP_HOST_ID,sessionID.id,16);
- atom.writeInt(PCP_HOST_IP,rhost[0].ip);
- atom.writeShort(PCP_HOST_PORT,rhost[0].port);
- atom.writeInt(PCP_HOST_IP,rhost[1].ip);
- atom.writeShort(PCP_HOST_PORT,rhost[1].port);
- atom.writeInt(PCP_HOST_NUML,numListeners);
- atom.writeInt(PCP_HOST_NUMR,numRelays);
- atom.writeInt(PCP_HOST_UPTIME,upTime);
- atom.writeInt(PCP_HOST_VERSION,version);
- atom.writeInt(PCP_HOST_VERSION_VP,version_vp);
- if (version_ex_number){
- atom.writeBytes(PCP_HOST_VERSION_EX_PREFIX,version_ex_prefix,2);
- atom.writeShort(PCP_HOST_VERSION_EX_NUMBER,version_ex_number);
- }
- atom.writeChar(PCP_HOST_FLAGS1,fl1);
- atom.writeInt(PCP_HOST_OLDPOS,oldestPos);
- atom.writeInt(PCP_HOST_NEWPOS,newestPos);
- if (uphostdata){
- atom.writeInt(PCP_HOST_UPHOST_IP,uphost.ip);
- atom.writeInt(PCP_HOST_UPHOST_PORT,uphost.port);
- atom.writeInt(PCP_HOST_UPHOST_HOPS,uphostHops);
- }
+ atom.writeParent(PCP_HOST,13 + (addChan?1:0) + (uphostdata?3:0) + (version_ex_number?2:0) + (clap_pp?1:0/*JP-MOD*/));
+
+ if (addChan)
+ atom.writeBytes(PCP_HOST_CHANID,chanID.id,16);
+ atom.writeBytes(PCP_HOST_ID,sessionID.id,16);
+ atom.writeInt(PCP_HOST_IP,rhost[0].ip);
+ atom.writeShort(PCP_HOST_PORT,rhost[0].port);
+ atom.writeInt(PCP_HOST_IP,rhost[1].ip);
+ atom.writeShort(PCP_HOST_PORT,rhost[1].port);
+ atom.writeInt(PCP_HOST_NUML,numListeners);
+ atom.writeInt(PCP_HOST_NUMR,numRelays);
+ atom.writeInt(PCP_HOST_UPTIME,upTime);
+ atom.writeInt(PCP_HOST_VERSION,version);
+ atom.writeInt(PCP_HOST_VERSION_VP,version_vp);
+ if (version_ex_number){
+ atom.writeBytes(PCP_HOST_VERSION_EX_PREFIX,version_ex_prefix,2);
+ atom.writeShort(PCP_HOST_VERSION_EX_NUMBER,version_ex_number);
+ }
+ atom.writeChar(PCP_HOST_FLAGS1,fl1);
+ atom.writeInt(PCP_HOST_OLDPOS,oldestPos);
+ atom.writeInt(PCP_HOST_NEWPOS,newestPos);
+ if (uphostdata){
+ atom.writeInt(PCP_HOST_UPHOST_IP,uphost.ip);
+ atom.writeInt(PCP_HOST_UPHOST_PORT,uphost.port);
+ atom.writeInt(PCP_HOST_UPHOST_HOPS,uphostHops);
+ }
+ if (clap_pp){ //JP-MOD
+ atom.writeInt(PCP_HOST_CLAP_PP,clap_pp);
+ }
}
// -----------------------------------
bool ChanHit::writeVariable(Stream &out, const String &var)
strcat(buf,buf2);
char h_name[128];
- if (ClientSocket::getHostname(h_name,rhost[0].ip))
+ if (ClientSocket::getHostname(h_name,sizeof(h_name),rhost[0].ip)) // BOF\91Î\8dô\82Á\82Û\82¢
{
strcat(buf,"[");
strcat(buf,h_name);
while (ch)
{
if (ch->host.ip && !ch->dead && ch->numHops)
- cnt += ch->numListeners;
+ cnt += (unsigned int)ch->numListeners > 3 ? 3 : ch->numListeners;
+ ch=ch->next;
+ }
+
+ return cnt;
+}
+
+// -----------------------------------
+int ChanHitList::numClaps() //JP-MOD
+{
+ int cnt=0;
+ ChanHit *ch = hit;
+ while (ch)
+ {
+ if (ch->host.ip && !ch->dead && ch->numHops && (ch->clap_pp & 1)){
+ cnt++;
+ }
ch=ch->next;
}
changed = true;
}
+ if(ppFlags != info.ppFlags) //JP-MOD
+ {
+ ppFlags = info.ppFlags;
+ changed = true;
+ }
+
if (!desc.isSame(info.desc)) //JP-EX
{
desc = info.desc;
numSkips = 0;
bcID.clear();
createdTime = 0;
+ ppFlags = 0; //JP-MOD
}
// -----------------------------------
void ChanInfo::readTrackXML(XML::Node *n)
char type[16];
atom.readString(type,sizeof(type),d);
contentType = ChanInfo::getTypeFromStr(type);
+ }else if (id == PCP_CHAN_INFO_PPFLAGS) //JP-MOD
+ {
+ ppFlags = (unsigned int)atom.readInt();
}else
atom.skip(c,d);
}
// -----------------------------------
void ChanInfo::writeInfoAtoms(AtomStream &atom)
{
- atom.writeParent(PCP_CHAN_INFO,7);
+ atom.writeParent(PCP_CHAN_INFO,7 + (ppFlags ? 1:0/*JP-MOD*/));
atom.writeString(PCP_CHAN_INFO_NAME,name.cstr());
atom.writeInt(PCP_CHAN_INFO_BITRATE,bitrate);
atom.writeString(PCP_CHAN_INFO_GENRE,genre.cstr());
atom.writeString(PCP_CHAN_INFO_URL,url.cstr());
atom.writeString(PCP_CHAN_INFO_DESC,desc.cstr());
atom.writeString(PCP_CHAN_INFO_COMMENT,comment.cstr());
- atom.writeString(PCP_CHAN_INFO_TYPE,getTypeStr(contentType));
+ atom.writeString(PCP_CHAN_INFO_TYPE,getTypeStr(contentType));
+ if(ppFlags)
+ atom.writeInt(PCP_CHAN_INFO_PPFLAGS,ppFlags); //JP-MOD
}
// -----------------------------------
if (br)
bitrate = br;
+ { //JP-MOD
+ ppFlags = ServMgr::bcstNone;
+
+ if (n->findAttrInt("bcstClap"))
+ ppFlags |= ServMgr::bcstClap;
+ }
+
readXMLString(typeStr,n,"type");
if (!typeStr.isEmpty())
contentType = getTypeFromStr(typeStr.cstr());
char *hr = rf->findAttr("href");
if (hr)
{
- addURL(hr,"");
+ addURL(hr,"","");
//LOG("asx url %s",hr);
}
{
char *p = strstr(tmp,"=");
if (p)
- addURL(p+1,"");
+ addURL(p+1,"","");
}
}
}
while (in.readLine(tmp,sizeof(tmp)))
{
if (tmp[0] != '#')
- addURL(tmp,"");
+ addURL(tmp,"","");
}
}
// -----------------------------------
}
// -----------------------------------
+#define isHTMLSPECIAL(a) ((a == '&') || (a == '\"') || (a == '\'') || (a == '<') || (a == '>'))
+static void SJIStoSJISSAFE(char *string, size_t size)
+{
+ size_t pos;
+ for(pos = 0;
+ (string[pos] != '\0') && (pos < size);
+ ++pos)
+ {
+ if(isHTMLSPECIAL(string[pos]))
+ string[pos] = ' ';
+ }
+}
+
+// -----------------------------------
+static void WriteASXInfo(Stream &out, String &title, String &contacturl, String::TYPE tEncoding = String::T_UNICODESAFE) //JP-MOD
+{
+ if(!title.isEmpty())
+ {
+ String titleEncode;
+ titleEncode = title;
+ titleEncode.convertTo(tEncoding);
+ if(tEncoding == String::T_SJIS)
+ SJIStoSJISSAFE(titleEncode.cstr(), String::MAX_LEN);
+ out.writeLineF("<TITLE>%s</TITLE>", titleEncode.cstr());
+ }
+
+ if(!contacturl.isEmpty())
+ {
+ String contacturlEncode;
+ contacturlEncode = contacturl;
+ contacturlEncode.convertTo(tEncoding);
+ if(tEncoding == String::T_SJIS)
+ SJIStoSJISSAFE(contacturlEncode.cstr(), String::MAX_LEN);
+ out.writeLineF("<MOREINFO HREF = \"%s\" />", contacturlEncode.cstr());
+ }
+}
+
+// -----------------------------------
void PlayList::writeASX(Stream &out)
{
out.writeLine("<ASX Version=\"3.0\">");
+
+ String::TYPE tEncoding = String::T_SJIS;
+ if(servMgr->asxDetailedMode == 2)
+ {
+ out.writeLine("<PARAM NAME = \"Encoding\" VALUE = \"utf-8\" />"); //JP-MOD Memo: UTF-8 cannot be used in some recording software.
+ tEncoding = String::T_UNICODESAFE;
+ }
+
+ if(servMgr->asxDetailedMode)
+ WriteASXInfo(out, titles[0], contacturls[0], tEncoding); //JP-MOD
+
for(int i=0; i<numURLs; i++)
{
out.writeLine("<ENTRY>");
+ if(servMgr->asxDetailedMode)
+ WriteASXInfo(out, titles[i], contacturls[i], tEncoding); //JP-MOD
out.writeLineF("<REF href = \"%s\" />",urls[i].cstr());
out.writeLine("</ENTRY>");
}
char *nid = info.id.isSet()?idStr:info.name.cstr();
sprintf(url.cstr(),"%s/stream/%s%s",path,nid,ChanInfo::getTypeExt(info.contentType));
- addURL(url.cstr(),info.name);
+ addURL(url.cstr(),info.name,info.url);
}
// -----------------------------------
TrackInfo track;
::String desc,genre,url,comment;
+ unsigned int ppFlags; //JP-MOD
};
public:
void init();
void initLocal(int numl,int numr,int nums,int uptm,bool,bool,unsigned int,Channel*,unsigned int,unsigned int);
+ void initLocal_pp(bool isStealth, int numClaps); //JP-MOD
XML::Node *createXML();
void writeAtoms(AtomStream &,GnuID &);
Host host;
Host rhost[2];
unsigned int numListeners,numRelays,numHops;
+ int clap_pp; //JP-MOD
unsigned int time,upTime,lastContact;
unsigned int hitID;
GnuID sessionID,chanID;
void clearHits(bool);
int numHits();
int numListeners();
+ int numClaps(); //JP-MOD
int numRelays();
int numFirewalled();
int numTrackers();
int localListeners();
int localRelays();
+ int totalClaps(); //JP-MOD
int totalListeners();
int totalRelays();
::String sourceURL;
bool bump,stayConnected;
+ bool stealth; //JP-MOD
int icyMetaInterval;
unsigned int streamPos;
unsigned int skipCount; //JP-EX
bool readDelay;
+ int overrideMaxRelaysPerChannel; //JP-MOD
+ bool bClap; //JP-MOD
TYPE type;
ChannelSource *sourceData;
type = t;
urls = new ::String[max];
titles = new ::String[max];
+ contacturls = new ::String[max]; //JP-MOD
}
~PlayList()
{
delete [] urls;
delete [] titles;
+ delete [] contacturls; //JP-MOD
}
- void addURL(const char *url, const char *tit)
+ void addURL(const char *url, const char *tit, const char *contacturl/*JP-MOD*/)
{
if (numURLs < maxURLs)
{
urls[numURLs].set(url);
titles[numURLs].set(tit);
+ contacturls[numURLs].set(contacturl); //JP-MOD
numURLs++;
}
}
TYPE type;
int numURLs,maxURLs;
::String *urls,*titles;
+ ::String *contacturls; //JP-MOD
};
// ----------------------------------
,fwState(0)
,lastUpdate(0)
,lastCheckTime(0)
+ ,lastClapped(0) //JP-MOD
,parent(NULL)
{}
virtual ~ChannelStream() {}
int fwState;
unsigned int lastUpdate;
unsigned int lastCheckTime;
+ unsigned int lastClapped; //JP-MOD
Channel *parent;
};
if (str)
{
- int slen = strlen(str);
+ size_t slen = strlen(str);
mem.write((void *)str,slen+1); // string
}else
mem.writeChar(0); // null string
int HTML::getIntVariable(const String &varName,int loop)
{
String val;
+ LOG_DEBUG("AAA %d %d %d %d", val[0], val[1], val[2], val[3]);
MemoryStream mem(val.cstr(),String::MAX_LEN);
writeVariable(mem,varName,loop);
+ LOG_DEBUG("AAA %d %d %d %d", val[0], val[1], val[2], val[3]);
return atoi(val.cstr());
}
// --------------------------------------
writeVariable(mem,varName,loop);
+ String tmp;
+ tmp = varName;
+ LOG_DEBUG("*** %s : %c", tmp.cstr(), val[0]);
+
// integer
if ((val[0] >= '0') && (val[0] <= '9'))
return atoi(val.cstr()) != 0;
{
if (getBoolVariable(var,loop)==varCond)
{
+ LOG_DEBUG("==varCond, loop = %d", loop);
if (readTemplate(in,outp,loop))
readTemplate(in,NULL,loop);
}else{
+ LOG_DEBUG("!=varCond, loop = %d", loop);
if (readTemplate(in,NULL,loop))
readTemplate(in,outp,loop);
}
{
int cnt = getIntVariable(var,loop);
+ LOG_DEBUG("loop_cnt : %s = %d", var.cstr(), cnt);
+
if (cnt)
{
int spos = in.getPosition();
int PCPStream::readPacket(Stream &in,Channel *)
{
BroadcastState bcs;
+ bcs.ttl = 1;
return readPacket(in,bcs);
}
// ------------------------------------------
if (servMgr->autoBumpSkipCount) //JP-EX
{
- if (ch->skipCount > servMgr->autoBumpSkipCount)
+ if ((ch->skipCount > servMgr->autoBumpSkipCount) && !(servMgr->disableAutoBumpIfDirect && ch->sourceHost.tracker)) //JP-MOD
{
LOG_DEBUG("Auto bump");
ch->bump = true;
hit.uphost.port = atom.readInt();
else if (id == PCP_HOST_UPHOST_HOPS)
hit.uphostHops = atom.readInt();
- else
+ else if (id == PCP_HOST_CLAP_PP){ //JP-MOD
+ hit.clap_pp = atom.readInt();
+ if (hit.clap_pp & 1){
+ Channel *c = chanMgr->findChannelByID(chanID);
+ if(c && c->isBroadcasting()){
+ String sjis;
+ sjis = c->info.name;
+ sjis.convertTo(String::T_SJIS);
+ peercastApp->notifyMessage(ServMgr::NT_APPLAUSE, sjis);
+ }
+ }
+ }else
{
LOG_DEBUG("PCP skip: %s,%d,%d",id.getString().str(),c,d);
atom.skip(c,d);
hit.servent_id = bcs.servent_id;
- if (flg){
+ if (flg && (bcs.ttl != 0)){
// LOG_DEBUG("readHostAtoms HITLISTLOCK ON-------------");
chanMgr->hitlistlock.on();
if (hit.recv)
int PCPStream::readBroadcastAtoms(AtomStream &atom,int numc,BroadcastState &bcs)
{
ChanPacket pack;
- int ttl=0;
+ //int ttl=0;
int ver=0;
int ver_vp=0;
GnuID fromID,destID;
if (id == PCP_BCST_TTL)
{
- ttl = atom.readChar()-1;
- patom.writeChar(id,ttl);
-
+ bcs.ttl = atom.readChar()-1;
+ patom.writeChar(id,bcs.ttl);
}else if (id == PCP_BCST_HOPS)
{
bcs.numHops = atom.readChar()+1;
pmem.pos = oldPos;
r = readAtom(patom,bcs);
} else {
- LOG_DEBUG("### Invalid bcst: hops=%d, ver=%d(VP%04d), ttl=%d",
- bcs.numHops,ver,ver_vp,ttl);
- ttl = 0;
+ char tmp[80], tmp2[80], tmp3[80];
+ hit.uphost.toStr(tmp);
+ hit.host.toStr(tmp2);
+ sv->getHost().toStr(tmp3);
+ LOG_DEBUG("### Invalid bcst: hops=%d, l/r = %d/%d, ver=%d(VP%04d), ttl=%d",
+ bcs.numHops,hit.numListeners, hit.numRelays, ver,ver_vp,bcs.ttl);
+ LOG_DEBUG("### %s <- %s <- sv(%s)",
+ tmp2, tmp, tmp3);
+ bcs.ttl = 0;
}
} else {
// copy and process atoms
if (ver_ex_number){
LOG_DEBUG("PCP bcst: group=%d, hops=%d, ver=%d(%c%c%04d), from=%s, dest=%s ttl=%d",
- bcs.group,bcs.numHops,ver,ver_ex_prefix[0],ver_ex_prefix[1],ver_ex_number,fromStr,destStr,ttl);
+ bcs.group,bcs.numHops,ver,ver_ex_prefix[0],ver_ex_prefix[1],ver_ex_number,fromStr,destStr,bcs.ttl);
} else if (ver_vp){
- LOG_DEBUG("PCP bcst: group=%d, hops=%d, ver=%d(VP%04d), from=%s, dest=%s ttl=%d",bcs.group,bcs.numHops,ver,ver_vp,fromStr,destStr,ttl);
+ LOG_DEBUG("PCP bcst: group=%d, hops=%d, ver=%d(VP%04d), from=%s, dest=%s ttl=%d",bcs.group,bcs.numHops,ver,ver_vp,fromStr,destStr,bcs.ttl);
} else {
- LOG_DEBUG("PCP bcst: group=%d, hops=%d, ver=%d, from=%s, dest=%s ttl=%d",bcs.group,bcs.numHops,ver,fromStr,destStr,ttl);
+ LOG_DEBUG("PCP bcst: group=%d, hops=%d, ver=%d, from=%s, dest=%s ttl=%d",bcs.group,bcs.numHops,ver,fromStr,destStr,bcs.ttl);
}
if (fromID.isSet())
return PCP_ERROR_BCST+PCP_ERROR_LOOPBACK;
}
- // broadcast back out if ttl > 0
- if ((ttl>0) && (!bcs.forMe))
- {
- pack.len = pmem.pos;
- pack.type = ChanPacket::T_PCP;
-
- if (bcs.group & (/*PCP_BCST_GROUP_ROOT|*/PCP_BCST_GROUP_TRACKERS|PCP_BCST_GROUP_RELAYS))
+ // broadcast back out if ttl > 0
+ if ((bcs.ttl>0) && (!bcs.forMe))
{
- pack.priority = 11 - bcs.numHops;
- chanMgr->broadcastPacketUp(pack,bcs.chanID,remoteID,destID);
- }
+ pack.len = pmem.pos;
+ pack.type = ChanPacket::T_PCP;
- if (bcs.group & (/*PCP_BCST_GROUP_ROOT|*/PCP_BCST_GROUP_TRACKERS|PCP_BCST_GROUP_RELAYS))
- {
- servMgr->broadcastPacket(pack,bcs.chanID,remoteID,destID,Servent::T_COUT);
- }
+ if (bcs.group & (/*PCP_BCST_GROUP_ROOT|*/PCP_BCST_GROUP_TRACKERS|PCP_BCST_GROUP_RELAYS))
+ {
+ pack.priority = 11 - bcs.numHops;
+ chanMgr->broadcastPacketUp(pack,bcs.chanID,remoteID,destID);
+ }
- if (bcs.group & (PCP_BCST_GROUP_RELAYS|PCP_BCST_GROUP_TRACKERS))
- {
- servMgr->broadcastPacket(pack,bcs.chanID,remoteID,destID,Servent::T_CIN);
- }
+ if (bcs.group & (/*PCP_BCST_GROUP_ROOT|*/PCP_BCST_GROUP_TRACKERS|PCP_BCST_GROUP_RELAYS))
+ {
+ servMgr->broadcastPacket(pack,bcs.chanID,remoteID,destID,Servent::T_COUT);
+ }
- if (bcs.group & (PCP_BCST_GROUP_RELAYS))
- {
- servMgr->broadcastPacket(pack,bcs.chanID,remoteID,destID,Servent::T_RELAY);
- }
+ if (bcs.group & (PCP_BCST_GROUP_RELAYS|PCP_BCST_GROUP_TRACKERS))
+ {
+ servMgr->broadcastPacket(pack,bcs.chanID,remoteID,destID,Servent::T_CIN);
+ }
+ if (bcs.group & (PCP_BCST_GROUP_RELAYS))
+ {
+ servMgr->broadcastPacket(pack,bcs.chanID,remoteID,destID,Servent::T_RELAY);
+ }
-// LOG_DEBUG("ttl=%d",ttl);
- } else {
-// LOG_DEBUG("ttl=%d",ttl);
- }
+ // LOG_DEBUG("ttl=%d",ttl);
+
+ } else {
+ // LOG_DEBUG("ttl=%d",ttl);
+ }
return r;
}
static const ID4 PCP_HOST_VERSION_VP = "vevp";
static const ID4 PCP_HOST_VERSION_EX_PREFIX = "vexp";
static const ID4 PCP_HOST_VERSION_EX_NUMBER = "vexn";
+static const ID4 PCP_HOST_CLAP_PP = "clap"; //JP-MOD
static const ID4 PCP_HOST_FLAGS1 = "flg1";
static const ID4 PCP_HOST_OLDPOS = "oldp";
static const ID4 PCP_HOST_NEWPOS = "newp";
static const ID4 PCP_CHAN_INFO_URL = "url";
static const ID4 PCP_CHAN_INFO_DESC = "desc";
static const ID4 PCP_CHAN_INFO_COMMENT = "cmnt";
+static const ID4 PCP_CHAN_INFO_PPFLAGS = "pflg"; //JP-MOD
static const ID4 PCP_CHAN_TRACK = "trck";
static const ID4 PCP_CHAN_TRACK_TITLE = "titl";
,streamPos(0)
,group(0)
,servent_id(0)
+ ,ttl(0)
{
chanID.clear();
bcID.clear();
unsigned int streamPos;
int group;
int servent_id;
+ int ttl;
};
// ----------------------------------------------
#define new DEBUG_NEW
#endif
-
+#include "version2.h"
// ---------------------------------
// globals
PeercastInstance *peercastInst=NULL;
PeercastApplication *peercastApp=NULL;
+int version_ex = 0;
// ---------------------------------
void APICALL PeercastInstance::init()
#define DEBUG_NEW new(__FILE__, __LINE__)
#define new DEBUG_NEW
#endif
+
+static const int dummy = 0;
}
strcat(buf,h_ip);
char h_name[128];
- if (ClientSocket::getHostname(h_name,h.ip))
+ if (ClientSocket::getHostname(h_name,sizeof(h_name),h.ip)) //JP-MOD(BOF\91Î\8dô)
{
strcat(buf,"[");
strcat(buf,h_name);
{
if (str)
{
- int slen = strlen(str);
- for(int i=0; i<slen; i++)
+ size_t slen = strlen(str);
+ for(size_t i=0; i<slen; i++)
if (str[i]=='&') str[i] = 0;
}
}
if (pwdArg && songArg)
{
- int i;
- int slen = strlen(fn);
+ size_t i;
+ size_t slen = strlen(fn);
for(i=0; i<slen; i++)
if (fn[i]=='&') fn[i] = 0;
int newPort=servMgr->serverHost.port;
int enableGetName = 0;
int allowConnectPCST = 0;
+ int disableAutoBumpIfDirect = 0; //JP-MOD
+ int asxDetailedMode = 0; //JP-MOD
char *cp = cmd;
while (cp=nextCGIarg(cp,curr,arg))
{
+ LOG_DEBUG("ARG: %s = %s", curr, arg);
+
// server
if (strcmp(curr,"serveractive")==0)
servMgr->autoServe = getCGIargBOOL(arg);
{
servMgr->numFilters++;
servMgr->filters[servMgr->numFilters].init(); // clear new entry
+ LOG_DEBUG("numFilters = %d", servMgr->numFilters);
}
}else if (strncmp(fs,"bn",2)==0)
else if (strcmp(curr, "maxRelaysIndexTxt") ==0) // for PCRaw (relay)
servMgr->maxRelaysIndexTxt = getCGIargINT(arg);
+ else if (strcmp(curr, "disableAutoBumpIfDirect") ==0) //JP-MOD
+ disableAutoBumpIfDirect = atoi(arg) ? 1 : 0;
+ else if (strcmp(curr, "asxDetailedMode") ==0) //JP-MOD
+ asxDetailedMode = getCGIargINT(arg);
}
servMgr->allowServer2 = allowServer2;
servMgr->enableGetName = enableGetName;
servMgr->allowConnectPCST = allowConnectPCST;
+ servMgr->disableAutoBumpIfDirect = disableAutoBumpIfDirect; //JP-MOD
+ servMgr->asxDetailedMode = asxDetailedMode; //JP-MOD
if (!(servMgr->allowServer1 & ALLOW_HTML) && !(servMgr->allowServer2 & ALLOW_HTML))
servMgr->allowServer1 |= ALLOW_HTML;
}else if (strcmp(curr,"type")==0)
{
info.contentType = ChanInfo::getTypeFromStr(arg);
+ }else if (strcmp(curr,"bcstClap")==0) //JP-MOD
+ {
+ info.ppFlags |= ServMgr::bcstClap;
}
}
Channel *c = chanMgr->findChannelByName(chname.cstr());
if (c && (c->isActive()) && (c->status == Channel::S_BROADCASTING)){
ChanInfo newInfo = c->info;
+ newInfo.ppFlags = ServMgr::bcstNone; //JP-MOD
while (cmd=nextCGIarg(cmd,curr,arg))
{
String chmeta;
newInfo.genre = chmeta.cstr();
else if (strcmp(curr,"comment")==0)
newInfo.comment = chmeta.cstr();
+ else if (strcmp(curr,"bcstClap")==0) //JP-MOD
+ newInfo.ppFlags |= ServMgr::bcstClap;
else if (strcmp(curr,"t_contact")==0)
newInfo.track.contact = chmeta.cstr();
else if (strcmp(curr,"t_title")==0)
chanLog="";
maxRelaysIndexTxt = 1; // for PCRaw (relay)
+
+ { //JP-MOD
+#ifdef WIN32
+ guiSimpleChannelList = false;
+ guiSimpleConnectionList = false;
+ guiTopMost = false;
+
+ guiChanListDisplays = 10;
+ guiConnListDisplays = 10;
+
+ guiTitleModify = false;
+ guiTitleModifyNormal = "PeerCast \8eó\90M:%rx.kbits.1%kbps \91\97\90M:%tx.kbits.1%kbps";
+ guiTitleModifyMinimized = "R:%rx.kbytes%KB/s T:%tx.kbytes%KB/s";
+
+ guiAntennaNotifyIcon = false;
+#endif
+
+ disableAutoBumpIfDirect = 1;
+ asxDetailedMode = 1;
+ }
}
// -----------------------------------
BCID *ServMgr::findValidBCID(int index)
numFilters++;
+ LOG_DEBUG("numFilters = %d", numFilters);
}
// -----------------------------------
iniFile.writeIntValue("maxRelaysIndexTxt", servMgr->maxRelaysIndexTxt); // for PCRaw (relay)
+ { //JP-MOD
+ iniFile.writeIntValue("disableAutoBumpIfDirect",servMgr->disableAutoBumpIfDirect);
+ iniFile.writeIntValue("asxDetailedMode",servMgr->asxDetailedMode);
+
+ iniFile.writeSection("PP");
+#ifdef WIN32
+ iniFile.writeBoolValue("ppClapSound", servMgr->ppClapSound);
+ iniFile.writeStrValue("ppClapSoundPath", servMgr->ppClapSoundPath.cstr());
+#endif
+ }
+
//JP-EX
iniFile.writeSection("Windows");
iniFile.writeBoolValue("getModulePath",servMgr->getModulePath);
iniFile.writeIntValue("guiRight", winPlace.rcNormalPosition.right);
}
+ { //JP-MOD
+ iniFile.writeBoolValue("guiSimpleChannelList", servMgr->guiSimpleChannelList);
+ iniFile.writeBoolValue("guiSimpleConnectionList", servMgr->guiSimpleConnectionList);
+ iniFile.writeBoolValue("guiTopMost", servMgr->guiTopMost);
+
+ iniFile.writeIntValue("guiChanListDisplays", servMgr->guiChanListDisplays);
+ iniFile.writeIntValue("guiConnListDisplays", servMgr->guiConnListDisplays);
+
+ iniFile.writeBoolValue("guiTitleModify", servMgr->guiTitleModify);
+ iniFile.writeStrValue("guiTitleModifyNormal", servMgr->guiTitleModifyNormal.cstr());
+ iniFile.writeStrValue("guiTitleModifyMinimized", servMgr->guiTitleModifyMinimized.cstr());
+
+ iniFile.writeBoolValue("guiAntennaNotifyIcon", servMgr->guiAntennaNotifyIcon);
+ }
+
iniFile.writeBoolValue("topmostGui", servMgr->topmostGui);
iniFile.writeBoolValue("startWithGui", servMgr->startWithGui);
#endif
iniFile.writeBoolValue("PeerCast",notifyMask&NT_PEERCAST);
iniFile.writeBoolValue("Broadcasters",notifyMask&NT_BROADCASTERS);
iniFile.writeBoolValue("TrackInfo",notifyMask&NT_TRACKINFO);
+ iniFile.writeBoolValue("Applause",notifyMask&NT_APPLAUSE); //JP-MOD
iniFile.writeLine("[End]");
else if (iniFile.isName("maxRelaysIndexTxt")) // for PCRaw (relay)
servMgr->maxRelaysIndexTxt = iniFile.getIntValue();
+ //JP-MOD
+ else if (iniFile.isName("disableAutoBumpIfDirect"))
+ servMgr->disableAutoBumpIfDirect = iniFile.getIntValue();
+ else if (iniFile.isName("asxDetailedMode"))
+ servMgr->asxDetailedMode = iniFile.getIntValue();
+
+#ifdef WIN32
+ else if (iniFile.isName("ppClapSound"))
+ servMgr->ppClapSound = iniFile.getBoolValue();
+ else if (iniFile.isName("ppClapSoundPath"))
+ servMgr->ppClapSoundPath.set(iniFile.getStrValue(),String::T_ASCII);
+#endif
+
//JP-Windows
else if (iniFile.isName("getModulePath"))
servMgr->getModulePath = iniFile.getBoolValue();
if (servMgr->saveGuiPos){
guiFlg = true;
}
- }
+ }else if (iniFile.isName("guiSimpleChannelList")) //JP-MOD
+ servMgr->guiSimpleChannelList = iniFile.getBoolValue();
+ else if (iniFile.isName("guiSimpleConnectionList")) //JP-MOD
+ servMgr->guiSimpleConnectionList = iniFile.getBoolValue();
+ else if (iniFile.isName("guiTopMost")) //JP-MOD
+ servMgr->guiTopMost = iniFile.getBoolValue();
+ else if (iniFile.isName("guiChanListDisplays")) //JP-MOD
+ servMgr->guiChanListDisplays = iniFile.getIntValue();
+ else if (iniFile.isName("guiConnListDisplays")) //JP-MOD
+ servMgr->guiConnListDisplays = iniFile.getIntValue();
+ else if (iniFile.isName("guiTitleModify")) //JP-MOD
+ servMgr->guiTitleModify = iniFile.getBoolValue();
+ else if (iniFile.isName("guiTitleModifyNormal")) //JP-MOD
+ servMgr->guiTitleModifyNormal.set(iniFile.getStrValue(),String::T_ASCII);
+ else if (iniFile.isName("guiTitleModifyMinimized")) //JP-MOD
+ servMgr->guiTitleModifyMinimized.set(iniFile.getStrValue(),String::T_ASCII);
+ else if (iniFile.isName("guiAntennaNotifyIcon")) //JP-MOD
+ servMgr->guiAntennaNotifyIcon = iniFile.getBoolValue();
else if (iniFile.isName("topmostGui"))
{
if (numFilters < (MAX_FILTERS-1))
numFilters++;
+ LOG_DEBUG("*** numFilters = %d", numFilters);
}
else if (iniFile.isName("[Notify]"))
{
notifyMask |= iniFile.getBoolValue()?NT_BROADCASTERS:0;
else if (iniFile.isName("TrackInfo"))
notifyMask |= iniFile.getBoolValue()?NT_TRACKINFO:0;
+ else if (iniFile.isName("Applause")) //JP-MOD
+ notifyMask |= iniFile.getBoolValue()?NT_APPLAUSE:0;
}
}
if (!numFilters)
setFilterDefaults();
+ LOG_DEBUG("numFilters = %d", numFilters);
}
// --------------------------------------------------
#else
priv = "";
#endif
-#ifdef VERSION_EX
- LOG_DEBUG("Peercast %s, %s %s",PCX_VERSTRING_EX,peercastApp->getClientTypeOS(),priv);
-#else
- LOG_DEBUG("Peercast %s, %s %s",PCX_VERSTRING,peercastApp->getClientTypeOS(),priv);
-#endif
+ if (version_ex)
+ {
+ LOG_DEBUG("Peercast %s, %s %s",PCX_VERSTRING_EX,peercastApp->getClientTypeOS(),priv);
+ } else
+ {
+ LOG_DEBUG("Peercast %s, %s %s",PCX_VERSTRING,peercastApp->getClientTypeOS(),priv);
+ }
sessionID.toStr(idStr);
LOG_DEBUG("SessionID: %s",idStr);
atom.writeBytes(PCP_BCST_FROM,servMgr->sessionID.id,16);
atom.writeInt(PCP_BCST_VERSION,PCP_CLIENT_VERSION);
atom.writeInt(PCP_BCST_VERSION_VP,PCP_CLIENT_VERSION_VP);
-#ifdef VERSION_EX
- atom.writeBytes(PCP_BCST_VERSION_EX_PREFIX,PCP_CLIENT_VERSION_EX_PREFIX,2);
- atom.writeShort(PCP_BCST_VERSION_EX_NUMBER,PCP_CLIENT_VERSION_EX_NUMBER);
-#endif
+ if (version_ex)
+ {
+ atom.writeBytes(PCP_BCST_VERSION_EX_PREFIX,PCP_CLIENT_VERSION_EX_PREFIX,2);
+ atom.writeShort(PCP_BCST_VERSION_EX_NUMBER,PCP_CLIENT_VERSION_EX_NUMBER);
+ }
atom.writeParent(PCP_PUSH,3);
atom.writeInt(PCP_PUSH_IP,to.ip);
atom.writeShort(PCP_PUSH_PORT,to.port);
ChanPacket pack;
MemoryStream mem(pack.data,sizeof(pack.data));
AtomStream atom(mem);
-#ifndef VERSION_EX
+ if (version_ex == 0)
+ {
atom.writeParent(PCP_BCST,7);
-#else
+ } else
+ {
atom.writeParent(PCP_BCST,9);
-#endif
- atom.writeChar(PCP_BCST_GROUP,PCP_BCST_GROUP_TRACKERS);
- atom.writeChar(PCP_BCST_HOPS,0);
- atom.writeChar(PCP_BCST_TTL,7);
- atom.writeBytes(PCP_BCST_FROM,sessionID.id,16);
- atom.writeInt(PCP_BCST_VERSION,PCP_CLIENT_VERSION);
- atom.writeInt(PCP_BCST_VERSION_VP,PCP_CLIENT_VERSION_VP);
-#ifdef VERSION_EX
+ }
+ atom.writeChar(PCP_BCST_GROUP,PCP_BCST_GROUP_TRACKERS);
+ atom.writeChar(PCP_BCST_HOPS,0);
+ atom.writeChar(PCP_BCST_TTL,7);
+ atom.writeBytes(PCP_BCST_FROM,sessionID.id,16);
+ atom.writeInt(PCP_BCST_VERSION,PCP_CLIENT_VERSION);
+ atom.writeInt(PCP_BCST_VERSION_VP,PCP_CLIENT_VERSION_VP);
+ if (version_ex)
+ {
atom.writeBytes(PCP_BCST_VERSION_EX_PREFIX,PCP_CLIENT_VERSION_EX_PREFIX,2);
atom.writeShort(PCP_BCST_VERSION_EX_NUMBER,PCP_CLIENT_VERSION_EX_NUMBER);
-#endif
- writeRootAtoms(atom,getUpdate);
+ }
+ writeRootAtoms(atom,getUpdate);
mem.len = mem.pos;
mem.rewind();
String str;
if (var == "version")
-#ifdef VERSION_EX
- strcpy(buf,PCX_VERSTRING_EX);
-#else
- strcpy(buf,PCX_VERSTRING);
-#endif
+ if (version_ex)
+ {
+ strcpy(buf,PCX_VERSTRING_EX);
+ } else
+ {
+ strcpy(buf,PCX_VERSTRING);
+ }
else if (var == "uptime")
{
str.setFromStopwatch(getUptime());
sprintf(buf,"%d",getFirewall()==FW_UNKNOWN?0:1);
else if (var == "rootMsg")
strcpy(buf,rootMsg);
- else if (var == "isRoot")
+ else if (var == "isRoot"){
+ LOG_DEBUG("isRoot = %d", isRoot);
sprintf(buf,"%d",isRoot?1:0);
+ }
else if (var == "isPrivate")
sprintf(buf,"%d",(PCP_BROADCAST_FLAGS&1)?1:0);
else if (var == "forceYP")
sprintf(buf,"%d",maxControl);
else if (var == "maxServIn")
sprintf(buf,"%d",maxServIn);
- else if (var == "numFilters")
+ else if (var == "numFilters") {
+ LOG_DEBUG("*-* numFilters = %d", numFilters);
sprintf(buf,"%d",numFilters+1);
+ }
else if (var == "maxPGNUIn")
sprintf(buf,"%d",maxGnuIncoming);
else if (var == "minPGNUIn")
else if (var == "enableGetName")
strcpy(buf, (enableGetName == 1)? "1":"0");
+ //JP-MOD
+ else if (var == "disableAutoBumpIfDirect")
+ strcpy(buf, (disableAutoBumpIfDirect == 1) ? "1":"0");
+ else if (var.startsWith("asxDetailedMode"))
+ {
+ if (var == "asxDetailedMode.0")
+ strcpy(buf, (asxDetailedMode == 0) ? "1":"0");
+ else if (var == "asxDetailedMode.1")
+ strcpy(buf, (asxDetailedMode == 1) ? "1":"0");
+ else if (var == "asxDetailedMode.2")
+ strcpy(buf, (asxDetailedMode == 2) ? "1":"0");
+ }
+
// VP-EX
else if (var == "ypAddress2")
strcpy(buf,rootHost2.cstr());
NT_UPGRADE = 0x0001,
NT_PEERCAST = 0x0002,
NT_BROADCASTERS = 0x0004,
- NT_TRACKINFO = 0x0008
+ NT_TRACKINFO = 0x0008,
+ NT_APPLAUSE = 0x0010 //JP-MOD
};
enum FW_STATE
int maxRelaysIndexTxt; // for PCRaw (relay)
+#ifdef WIN32 //JP-MOD
+ bool guiSimpleChannelList;
+ bool guiSimpleConnectionList;
+ bool guiTopMost;
+
+ int guiChanListDisplays;
+ int guiConnListDisplays;
+ bool guiTitleModify;
+ String guiTitleModifyNormal;
+ String guiTitleModifyMinimized;
+
+ bool guiAntennaNotifyIcon;
+
+ bool ppClapSound;
+ String ppClapSoundPath;
+#endif
+
+ int disableAutoBumpIfDirect;
+ int asxDetailedMode;
+
+ enum PPBCSTFLAG //JP-MOD
+ {
+ bcstNone = 0x00000000,
+ bcstClap = 0x00000001
+ };
+
private:
FW_STATE firewalled;
};
static unsigned int getIP(char *);
- static bool getHostname(char *,unsigned int);
+ static bool getHostname(char *,size_t,unsigned int); //JP-MOD
virtual bool eof()
{
{
lock.on();
- unsigned int len = strlen(str);
+ size_t len = strlen(str);
int cnt=0;
while (len)
{
- unsigned int rlen = len;
+ size_t rlen = len;
if (rlen > (lineLen-1))
rlen = lineLen-1;
// set from null terminated string, remove first/last chars
void setUnquote(const char *p, TYPE t=T_ASCII)
{
- int slen = strlen(p);
+ size_t slen = strlen(p);
if (slen > 2)
{
if (slen >= MAX_LEN) slen = MAX_LEN;
void clear()
{
+ memset(data, 0, MAX_LEN);
data[0]=0;
type = T_UNKNOWN;
}
typedef __int64 int64_t;
+#ifndef _UINTPTR_T_DEFINED
+typedef unsigned int uintptr_t;
+#endif
// ------------------------------------
class WEvent
// ------------------------------------
typedef int (WINAPI *THREAD_FUNC)(ThreadInfo *);
-typedef unsigned int THREAD_HANDLE;
+typedef uintptr_t THREAD_HANDLE;
#define THREAD_PROC int WINAPI
#define vsnprintf _vsnprintf
#endif
// ------------------------------------------------
static const int PCP_CLIENT_VERSION = 1218;
-static const int PCP_CLIENT_VERSION_VP = 26;
+static const int PCP_CLIENT_VERSION_VP = 27;
static const int PCP_ROOT_VERSION = 1218;
static const int PCP_CLIENT_MINVERSION = 1200;
static const char *PCX_AGENT = "PeerCast/0.1218";
static const char *PCX_AGENTJP = "PeerCast/0.1218-J";
-static const char *PCX_AGENTVP = "PeerCast/0.1218(VP0026)";
-static const char *PCX_VERSTRING = "v0.1218(VP0026)";
+static const char *PCX_AGENTVP = "PeerCast/0.1218(VP0027)";
+static const char *PCX_VERSTRING = "v0.1218(VP0027)";
+
+extern int version_ex; // PP\94Å\8ag\92£\8b@\94\\97L\8cø\89»\83t\83\89\83O(\82½\82Ô\82ñ)
#if 1 /* for VP extend version */
-#define VERSION_EX 1
+//#define VERSION_EX 1
static const char *PCP_CLIENT_VERSION_EX_PREFIX = "IM"; // 2bytes only
static const int PCP_CLIENT_VERSION_EX_NUMBER = 27;
-static const char *PCX_AGENTEX = "PeerCast/0.1218(IM0027)";
-static const char *PCX_VERSTRING_EX = "v0.1218(IM0027)";
+static const char *PCX_AGENTEX = "PeerCast/0.1218(IM0027-2)";
+static const char *PCX_VERSTRING_EX = "v0.1218(IM0027-2)";
#endif
// ------------------------------------------------
// ----------------------------------
char *XML::Node::findAttr(const char *name)
{
- int nlen = strlen(name);
+ size_t nlen = strlen(name);
for(int i=1; i<numAttr; i++)
{
char *an = getAttrName(i);
#include <windows.h>
#include <stdio.h>
#include "wsocket.h"
-#include "stats.h"
+#include "..\common\stats.h"
#ifdef _DEBUG
#include "chkMemoryLeak.h"
#define DEBUG_NEW new(__FILE__, __LINE__)
}
// --------------------------------------------------
-bool ClientSocket::getHostname(char *str,unsigned int ip)
+bool ClientSocket::getHostname(char *str,size_t size,unsigned int ip) //JP-MOD
{
+ if(size == 0)
+ return false;
+
HOSTENT *he;
ip = htonl(ip);
if (he)
{
- strcpy(str,he->h_name);
+ LOG_DEBUG("getHostname: %d.%d.%d.%d -> %s", ((BYTE*)&ip)[0], ((BYTE*)&ip)[1], ((BYTE*)&ip)[2], ((BYTE*)&ip)[3], he->h_name);
+ strncpy(str,he->h_name,size-1);
+ str[size-1] = '\0';
return true;
}else
return false;
int fromSize = sizeof(sockaddr_in);
sockaddr_in from;
- int conSock = ::accept(sockNum,(sockaddr *)&from,&fromSize);
+ SOCKET conSock = ::accept(sockNum,(sockaddr *)&from,&fromSize);
if (conSock == INVALID_SOCKET)
#define _WSOCKET_H
#include <windows.h>
-#include "socket.h"
+#include "..\common\socket.h"
//#include "winsock2.h"
void checkBuffering(bool, bool);
unsigned int writeCnt;
- unsigned int sockNum;
+ SOCKET sockNum;
struct sockaddr_in remoteAddr;
enum {RBSIZE = 8192};
#include <process.h>
#include <windows.h>
#include <time.h>
-#include "win32/wsys.h"
-#include "win32/wsocket.h"
-#include "stats.h"
-#include "peercast.h"
+#include "wsys.h"
+#include "wsocket.h"
+#include "..\common\stats.h"
+#include "..\common\peercast.h"
#include <sys/timeb.h>
#include <time.h>
#include "shellapi.h"
{
time_t ltime;
time( <ime );
- return ltime;
+ return (unsigned)ltime;
}
// ---------------------------------
#define _WSYS_H
// ------------------------------------
#include <windows.h>
-#include "socket.h"
-#include "sys.h"
+#include "..\common\socket.h"
+#include "..\common\sys.h"
// ------------------------------------
class WSys : public Sys
hInst = hInstance;
+ version_ex = 0; // PP\94Å\8ag\92£\8b@\94\\82ð\96³\8cø\82É
+
iniFileName.set(".\\peercast.ini");
WIN32_FIND_DATA fd; //JP-EX
case WM_INITDIALOG:
//SendDlgItemMessage(hDlg,IDC_ABOUTVER,WM_SETTEXT,0,(LONG)PCX_AGENT);
// SendDlgItemMessage(hDlg,IDC_ABOUTVER,WM_SETTEXT,0,(LONG)PCX_AGENTJP);
-#ifdef VERSION_EX
- SendDlgItemMessage(hDlg,IDC_ABOUTVER,WM_SETTEXT,0,(LONG)PCX_AGENTEX);
-#else
- SendDlgItemMessage(hDlg,IDC_ABOUTVER,WM_SETTEXT,0,(LONG)PCX_AGENTVP);
-#endif
+ if (version_ex)
+ {
+ SendDlgItemMessage(hDlg,IDC_ABOUTVER,WM_SETTEXT,0,(LONG)PCX_AGENTEX);
+ } else
+ {
+ SendDlgItemMessage(hDlg,IDC_ABOUTVER,WM_SETTEXT,0,(LONG)PCX_AGENTVP);
+ }
+
return TRUE;
case WM_COMMAND:
// for PCRaw start.
bool isIndexTxt(ChanInfo *info)
{
- int len;
+ size_t len;
if( info &&
info->contentType == ChanInfo::T_RAW &&
mount.clear();
bump = false;
stayConnected = false;
+ stealth = false; //JP-MOD
+ overrideMaxRelaysPerChannel = -1; //JP-MOD
+ bClap = false; //JP-MOD
icyMetaInterval = 0;
streamPos = 0;
return tot;
}
-
-
+// -----------------------------------
+int Channel::totalClaps() //JP-MOD
+{
+ ChanHitList *chl = chanMgr->findHitListByID(info.id);
+ return chl ? chl->numClaps() : 0;
+}
// -----------------------------------
void Channel::startGet()
if (!chl)
throw StreamException("Broadcast channel has no hitlist");
- int numListeners = totalListeners();
- int numRelays = totalRelays();
+ int numListeners = stealth ? -1 : totalListeners(); //JP-MOD \83\8a\83X\83i\81[\90\94\89B\95Á\8b@\94\
+ int numRelays = stealth ? -1 : totalRelays(); //JP-MOD \83\8a\83\8c\81[\90\94\89B\95Á\8b@\94\
unsigned int oldp = rawData.getOldestPos();
unsigned int newp = rawData.getLatestPos();
hit.initLocal(numListeners,numRelays,info.numSkips,info.getUptime(),isPlaying(), false, 0, this, oldp,newp);
hit.tracker = true;
-#ifndef VERSION_EX
- atom.writeParent(PCP_BCST,8);
-#else
- atom.writeParent(PCP_BCST,10);
-#endif
- atom.writeChar(PCP_BCST_GROUP,PCP_BCST_GROUP_ROOT);
- atom.writeChar(PCP_BCST_HOPS,0);
- atom.writeChar(PCP_BCST_TTL,11);
- atom.writeBytes(PCP_BCST_FROM,servMgr->sessionID.id,16);
- atom.writeInt(PCP_BCST_VERSION,PCP_CLIENT_VERSION);
- atom.writeInt(PCP_BCST_VERSION_VP,PCP_CLIENT_VERSION_VP);
-#ifdef VERSION_EX
+ if (version_ex == 0)
+ {
+ atom.writeParent(PCP_BCST,8);
+ } else
+ {
+ atom.writeParent(PCP_BCST,10);
+ }
+ atom.writeChar(PCP_BCST_GROUP,PCP_BCST_GROUP_ROOT);
+ atom.writeChar(PCP_BCST_HOPS,0);
+ atom.writeChar(PCP_BCST_TTL,11);
+ atom.writeBytes(PCP_BCST_FROM,servMgr->sessionID.id,16);
+ atom.writeInt(PCP_BCST_VERSION,PCP_CLIENT_VERSION);
+ atom.writeInt(PCP_BCST_VERSION_VP,PCP_CLIENT_VERSION_VP);
+
+ if (version_ex)
+ {
atom.writeBytes(PCP_BCST_VERSION_EX_PREFIX,PCP_CLIENT_VERSION_EX_PREFIX,2);
atom.writeShort(PCP_BCST_VERSION_EX_NUMBER,PCP_CLIENT_VERSION_EX_NUMBER);
-#endif
- atom.writeParent(PCP_CHAN,4);
- atom.writeBytes(PCP_CHAN_ID,info.id.id,16);
- atom.writeBytes(PCP_CHAN_BCID,chanMgr->broadcastID.id,16);
- info.writeInfoAtoms(atom);
- info.writeTrackAtoms(atom);
- hit.writeAtoms(atom,info.id);
+ }
+ atom.writeParent(PCP_CHAN,4);
+ atom.writeBytes(PCP_CHAN_ID,info.id.id,16);
+ atom.writeBytes(PCP_CHAN_BCID,chanMgr->broadcastID.id,16);
+ info.writeInfoAtoms(atom);
+ info.writeTrackAtoms(atom);
+ hit.writeAtoms(atom,info.id);
pack.len = mem.pos;
AtomStream atom(mem);
-#ifndef VERSION_EX
- atom.writeParent(PCP_BCST,8);
-#else
- atom.writeParent(PCP_BCST,10);
-#endif
- atom.writeChar(PCP_BCST_HOPS,0);
- atom.writeChar(PCP_BCST_TTL,7);
- atom.writeChar(PCP_BCST_GROUP,PCP_BCST_GROUP_RELAYS);
- atom.writeBytes(PCP_BCST_FROM,servMgr->sessionID.id,16);
- atom.writeInt(PCP_BCST_VERSION,PCP_CLIENT_VERSION);
- atom.writeInt(PCP_BCST_VERSION_VP,PCP_CLIENT_VERSION_VP);
-#ifdef VERSION_EX
+ if (version_ex == 0)
+ {
+ atom.writeParent(PCP_BCST,8);
+ } else
+ {
+ atom.writeParent(PCP_BCST,10);
+ }
+ atom.writeChar(PCP_BCST_HOPS,0);
+ atom.writeChar(PCP_BCST_TTL,7);
+ atom.writeChar(PCP_BCST_GROUP,PCP_BCST_GROUP_RELAYS);
+ atom.writeBytes(PCP_BCST_FROM,servMgr->sessionID.id,16);
+ atom.writeInt(PCP_BCST_VERSION,PCP_CLIENT_VERSION);
+ atom.writeInt(PCP_BCST_VERSION_VP,PCP_CLIENT_VERSION_VP);
+ if (version_ex)
+ {
atom.writeBytes(PCP_BCST_VERSION_EX_PREFIX,PCP_CLIENT_VERSION_EX_PREFIX,2);
atom.writeShort(PCP_BCST_VERSION_EX_NUMBER,PCP_CLIENT_VERSION_EX_NUMBER);
-#endif
- atom.writeBytes(PCP_BCST_CHANID,info.id.id,16);
- atom.writeParent(PCP_CHAN,3);
- atom.writeBytes(PCP_CHAN_ID,info.id.id,16);
- info.writeInfoAtoms(atom);
- info.writeTrackAtoms(atom);
+ }
+ atom.writeBytes(PCP_BCST_CHANID,info.id.id,16);
+ atom.writeParent(PCP_CHAN,3);
+ atom.writeBytes(PCP_CHAN_ID,info.id.id,16);
+ info.writeInfoAtoms(atom);
+ info.writeTrackAtoms(atom);
pack.len = mem.pos;
pack.type = ChanPacket::T_PCP;
// LOG_DEBUG("isPlaying-------------------------------------- %d %d", ch->isPlaying(), isPlaying);
hit.initLocal(newLocalListeners,newLocalRelays,ch->info.numSkips,ch->info.getUptime(),ch->isPlaying(), ch->isFull(), ch->info.bitrate, ch, oldp, newp);
+ { //JP-MOD
+ if(!(ch->info.ppFlags & ServMgr::bcstClap))
+ ch->bClap = false;
+ hit.initLocal_pp(ch->stealth, ch->bClap ? 1 : 0);
+ }
hit.tracker = ch->isBroadcasting();
if ( (((ctime-lastUpdate)>chanMgr->hostUpdateInterval) && chanMgr->hostUpdateInterval)
|| (ch->chDisp.relay != hit.relay)
|| (ch->chDisp.relayfull != hit.relayfull)
|| (ch->chDisp.chfull != hit.chfull)
- || (ch->chDisp.ratefull != hit.ratefull)
+ || (ch->chDisp.ratefull != hit.ratefull)
+ || (ch->bClap && ((ctime-lastClapped) > 60)) //JP-MOD
){
numListeners = newLocalListeners;
numRelays = newLocalRelays;
isPlaying = ch->isPlaying();
fwState = servMgr->getFirewall();
lastUpdate = ctime;
+
+ if(ch->bClap){ //JP-MOD
+ lastClapped = ctime;
+ ch->bClap = false;
+ }
ch->chDisp = hit;
GnuID noID;
noID.clear();
-#ifndef VERSION_EX
+ if (version_ex == 0)
+ {
atom.writeParent(PCP_BCST,8);
-#else
+ } else
+ {
atom.writeParent(PCP_BCST,10);
-#endif
- atom.writeChar(PCP_BCST_GROUP,PCP_BCST_GROUP_TRACKERS);
- atom.writeChar(PCP_BCST_HOPS,0);
- atom.writeChar(PCP_BCST_TTL,11);
- atom.writeBytes(PCP_BCST_FROM,servMgr->sessionID.id,16);
- atom.writeInt(PCP_BCST_VERSION,PCP_CLIENT_VERSION);
- atom.writeInt(PCP_BCST_VERSION_VP,PCP_CLIENT_VERSION_VP);
-#ifdef VERSION_EX
+ }
+ atom.writeChar(PCP_BCST_GROUP,PCP_BCST_GROUP_TRACKERS);
+ atom.writeChar(PCP_BCST_HOPS,0);
+ atom.writeChar(PCP_BCST_TTL,11);
+ atom.writeBytes(PCP_BCST_FROM,servMgr->sessionID.id,16);
+ atom.writeInt(PCP_BCST_VERSION,PCP_CLIENT_VERSION);
+ atom.writeInt(PCP_BCST_VERSION_VP,PCP_CLIENT_VERSION_VP);
+ if (version_ex)
+ {
atom.writeBytes(PCP_BCST_VERSION_EX_PREFIX,PCP_CLIENT_VERSION_EX_PREFIX,2);
atom.writeShort(PCP_BCST_VERSION_EX_NUMBER,PCP_CLIENT_VERSION_EX_NUMBER);
-#endif
- atom.writeBytes(PCP_BCST_CHANID,ch->info.id.id,16);
- hit.writeAtoms(atom,noID);
+ }
+ atom.writeBytes(PCP_BCST_CHANID,ch->info.id.id,16);
+ hit.writeAtoms(atom,noID);
pack.len = pmem.pos;
pack.type = ChanPacket::T_PCP;
else if (var == "numChannels")
sprintf(buf,"%d",numChannels());
else if (var == "djMessage")
- strcpy(buf,broadcastMsg.cstr());
+ {
+ String utf8 = broadcastMsg;
+ utf8.convertTo(String::T_UNICODESAFE);
+ strcpy(buf,utf8.cstr());
+ }
else if (var == "icyMetaInterval")
sprintf(buf,"%d",icyMetaInterval);
else if (var == "maxRelaysPerChannel")
utf8 = info.comment;
utf8.convertTo(String::T_UNICODESAFE);
strcpy(buf,utf8.cstr());
+ }else if (var == "bcstClap") //JP-MOD
+ {
+ strcpy(buf,info.ppFlags & ServMgr::bcstClap ? "1":"0");
}else if (var == "uptime")
{
String uptime;
sprintf(buf,"%d",totalRelays());
else if (var == "totalListeners")
sprintf(buf,"%d",totalListeners());
-
+ else if (var == "totalClaps") //JP-MOD
+ sprintf(buf,"%d",totalClaps());
else if (var == "status")
sprintf(buf,"%s",getStatusStr());
else if (var == "keep")
numListeners = 0;
numRelays = 0;
+ clap_pp = 0; //JP-MOD
dead = tracker = firewalled = stable = yp = false;
recv = cin = direct = relay = true;
version = PCP_CLIENT_VERSION;
version_vp = PCP_CLIENT_VERSION_VP;
-#ifdef VERSION_EX
- strncpy(version_ex_prefix, PCP_CLIENT_VERSION_EX_PREFIX,2);
- version_ex_number = PCP_CLIENT_VERSION_EX_NUMBER;
-#else
- version_ex_prefix[0] = ' ';
- version_ex_prefix[1] = ' ';
- version_ex_number = 0;
-#endif
+ if (version_ex)
+ {
+ strncpy(version_ex_prefix, PCP_CLIENT_VERSION_EX_PREFIX,2);
+ version_ex_number = PCP_CLIENT_VERSION_EX_NUMBER;
+ } else
+ {
+ version_ex_prefix[0] = ' ';
+ version_ex_prefix[1] = ' ';
+ version_ex_number = 0;
+ }
status = ch->status;
}
// -----------------------------------
+void ChanHit::initLocal_pp(bool isStealth, int numClaps) //JP-MOD
+{
+ numListeners = numListeners && !isStealth ? 1 : 0;
+ clap_pp = numClaps;
+}
+
+// -----------------------------------
void ChanHit::writeAtoms(AtomStream &atom,GnuID &chanID)
{
bool addChan=chanID.isSet();
if (tracker) fl1 |= PCP_HOST_FLAGS1_TRACKER;
if (firewalled) fl1 |= PCP_HOST_FLAGS1_PUSH;
- atom.writeParent(PCP_HOST,13 + (addChan?1:0) + (uphostdata?3:0) + (version_ex_number?2:0));
-
- if (addChan)
- atom.writeBytes(PCP_HOST_CHANID,chanID.id,16);
- atom.writeBytes(PCP_HOST_ID,sessionID.id,16);
- atom.writeInt(PCP_HOST_IP,rhost[0].ip);
- atom.writeShort(PCP_HOST_PORT,rhost[0].port);
- atom.writeInt(PCP_HOST_IP,rhost[1].ip);
- atom.writeShort(PCP_HOST_PORT,rhost[1].port);
- atom.writeInt(PCP_HOST_NUML,numListeners);
- atom.writeInt(PCP_HOST_NUMR,numRelays);
- atom.writeInt(PCP_HOST_UPTIME,upTime);
- atom.writeInt(PCP_HOST_VERSION,version);
- atom.writeInt(PCP_HOST_VERSION_VP,version_vp);
- if (version_ex_number){
- atom.writeBytes(PCP_HOST_VERSION_EX_PREFIX,version_ex_prefix,2);
- atom.writeShort(PCP_HOST_VERSION_EX_NUMBER,version_ex_number);
- }
- atom.writeChar(PCP_HOST_FLAGS1,fl1);
- atom.writeInt(PCP_HOST_OLDPOS,oldestPos);
- atom.writeInt(PCP_HOST_NEWPOS,newestPos);
- if (uphostdata){
- atom.writeInt(PCP_HOST_UPHOST_IP,uphost.ip);
- atom.writeInt(PCP_HOST_UPHOST_PORT,uphost.port);
- atom.writeInt(PCP_HOST_UPHOST_HOPS,uphostHops);
- }
+ atom.writeParent(PCP_HOST,13 + (addChan?1:0) + (uphostdata?3:0) + (version_ex_number?2:0) + (clap_pp?1:0/*JP-MOD*/));
+
+ if (addChan)
+ atom.writeBytes(PCP_HOST_CHANID,chanID.id,16);
+ atom.writeBytes(PCP_HOST_ID,sessionID.id,16);
+ atom.writeInt(PCP_HOST_IP,rhost[0].ip);
+ atom.writeShort(PCP_HOST_PORT,rhost[0].port);
+ atom.writeInt(PCP_HOST_IP,rhost[1].ip);
+ atom.writeShort(PCP_HOST_PORT,rhost[1].port);
+ atom.writeInt(PCP_HOST_NUML,numListeners);
+ atom.writeInt(PCP_HOST_NUMR,numRelays);
+ atom.writeInt(PCP_HOST_UPTIME,upTime);
+ atom.writeInt(PCP_HOST_VERSION,version);
+ atom.writeInt(PCP_HOST_VERSION_VP,version_vp);
+ if (version_ex_number){
+ atom.writeBytes(PCP_HOST_VERSION_EX_PREFIX,version_ex_prefix,2);
+ atom.writeShort(PCP_HOST_VERSION_EX_NUMBER,version_ex_number);
+ }
+ atom.writeChar(PCP_HOST_FLAGS1,fl1);
+ atom.writeInt(PCP_HOST_OLDPOS,oldestPos);
+ atom.writeInt(PCP_HOST_NEWPOS,newestPos);
+ if (uphostdata){
+ atom.writeInt(PCP_HOST_UPHOST_IP,uphost.ip);
+ atom.writeInt(PCP_HOST_UPHOST_PORT,uphost.port);
+ atom.writeInt(PCP_HOST_UPHOST_HOPS,uphostHops);
+ }
+ if (clap_pp){ //JP-MOD
+ atom.writeInt(PCP_HOST_CLAP_PP,clap_pp);
+ }
}
// -----------------------------------
bool ChanHit::writeVariable(Stream &out, const String &var)
strcat(buf,buf2);
char h_name[128];
- if (ClientSocket::getHostname(h_name,rhost[0].ip))
+ if (ClientSocket::getHostname(h_name,sizeof(h_name),rhost[0].ip)) // BOF\91Î\8dô\82Á\82Û\82¢
{
strcat(buf,"[");
strcat(buf,h_name);
while (ch)
{
if (ch->host.ip && !ch->dead && ch->numHops)
- cnt += ch->numListeners;
+ cnt += (unsigned int)ch->numListeners > 3 ? 3 : ch->numListeners;
+ ch=ch->next;
+ }
+
+ return cnt;
+}
+
+// -----------------------------------
+int ChanHitList::numClaps() //JP-MOD
+{
+ int cnt=0;
+ ChanHit *ch = hit;
+ while (ch)
+ {
+ if (ch->host.ip && !ch->dead && ch->numHops && (ch->clap_pp & 1)){
+ cnt++;
+ }
ch=ch->next;
}
changed = true;
}
+ if(ppFlags != info.ppFlags) //JP-MOD
+ {
+ ppFlags = info.ppFlags;
+ changed = true;
+ }
+
if (!desc.isSame(info.desc)) //JP-EX
{
desc = info.desc;
numSkips = 0;
bcID.clear();
createdTime = 0;
+ ppFlags = 0; //JP-MOD
}
// -----------------------------------
void ChanInfo::readTrackXML(XML::Node *n)
char type[16];
atom.readString(type,sizeof(type),d);
contentType = ChanInfo::getTypeFromStr(type);
+ }else if (id == PCP_CHAN_INFO_PPFLAGS) //JP-MOD
+ {
+ ppFlags = (unsigned int)atom.readInt();
}else
atom.skip(c,d);
}
// -----------------------------------
void ChanInfo::writeInfoAtoms(AtomStream &atom)
{
- atom.writeParent(PCP_CHAN_INFO,7);
+ atom.writeParent(PCP_CHAN_INFO,7 + (ppFlags ? 1:0/*JP-MOD*/));
atom.writeString(PCP_CHAN_INFO_NAME,name.cstr());
atom.writeInt(PCP_CHAN_INFO_BITRATE,bitrate);
atom.writeString(PCP_CHAN_INFO_GENRE,genre.cstr());
atom.writeString(PCP_CHAN_INFO_URL,url.cstr());
atom.writeString(PCP_CHAN_INFO_DESC,desc.cstr());
atom.writeString(PCP_CHAN_INFO_COMMENT,comment.cstr());
- atom.writeString(PCP_CHAN_INFO_TYPE,getTypeStr(contentType));
+ atom.writeString(PCP_CHAN_INFO_TYPE,getTypeStr(contentType));
+ if(ppFlags)
+ atom.writeInt(PCP_CHAN_INFO_PPFLAGS,ppFlags); //JP-MOD
}
// -----------------------------------
if (br)
bitrate = br;
+ { //JP-MOD
+ ppFlags = ServMgr::bcstNone;
+
+ if (n->findAttrInt("bcstClap"))
+ ppFlags |= ServMgr::bcstClap;
+ }
+
readXMLString(typeStr,n,"type");
if (!typeStr.isEmpty())
contentType = getTypeFromStr(typeStr.cstr());
char *hr = rf->findAttr("href");
if (hr)
{
- addURL(hr,"");
+ addURL(hr,"","");
//LOG("asx url %s",hr);
}
{
char *p = strstr(tmp,"=");
if (p)
- addURL(p+1,"");
+ addURL(p+1,"","");
}
}
}
while (in.readLine(tmp,sizeof(tmp)))
{
if (tmp[0] != '#')
- addURL(tmp,"");
+ addURL(tmp,"","");
}
}
// -----------------------------------
}
// -----------------------------------
+#define isHTMLSPECIAL(a) ((a == '&') || (a == '\"') || (a == '\'') || (a == '<') || (a == '>'))
+static void SJIStoSJISSAFE(char *string, size_t size)
+{
+ size_t pos;
+ for(pos = 0;
+ (string[pos] != '\0') && (pos < size);
+ ++pos)
+ {
+ if(isHTMLSPECIAL(string[pos]))
+ string[pos] = ' ';
+ }
+}
+
+// -----------------------------------
+static void WriteASXInfo(Stream &out, String &title, String &contacturl, String::TYPE tEncoding = String::T_UNICODESAFE) //JP-MOD
+{
+ if(!title.isEmpty())
+ {
+ String titleEncode;
+ titleEncode = title;
+ titleEncode.convertTo(tEncoding);
+ if(tEncoding == String::T_SJIS)
+ SJIStoSJISSAFE(titleEncode.cstr(), String::MAX_LEN);
+ out.writeLineF("<TITLE>%s</TITLE>", titleEncode.cstr());
+ }
+
+ if(!contacturl.isEmpty())
+ {
+ String contacturlEncode;
+ contacturlEncode = contacturl;
+ contacturlEncode.convertTo(tEncoding);
+ if(tEncoding == String::T_SJIS)
+ SJIStoSJISSAFE(contacturlEncode.cstr(), String::MAX_LEN);
+ out.writeLineF("<MOREINFO HREF = \"%s\" />", contacturlEncode.cstr());
+ }
+}
+
+// -----------------------------------
void PlayList::writeASX(Stream &out)
{
out.writeLine("<ASX Version=\"3.0\">");
+
+ String::TYPE tEncoding = String::T_SJIS;
+ if(servMgr->asxDetailedMode == 2)
+ {
+ out.writeLine("<PARAM NAME = \"Encoding\" VALUE = \"utf-8\" />"); //JP-MOD Memo: UTF-8 cannot be used in some recording software.
+ tEncoding = String::T_UNICODESAFE;
+ }
+
+ if(servMgr->asxDetailedMode)
+ WriteASXInfo(out, titles[0], contacturls[0], tEncoding); //JP-MOD
+
for(int i=0; i<numURLs; i++)
{
out.writeLine("<ENTRY>");
+ if(servMgr->asxDetailedMode)
+ WriteASXInfo(out, titles[i], contacturls[i], tEncoding); //JP-MOD
out.writeLineF("<REF href = \"%s\" />",urls[i].cstr());
out.writeLine("</ENTRY>");
}
char *nid = info.id.isSet()?idStr:info.name.cstr();
sprintf(url.cstr(),"%s/stream/%s%s",path,nid,ChanInfo::getTypeExt(info.contentType));
- addURL(url.cstr(),info.name);
+ addURL(url.cstr(),info.name,info.url);
}
// -----------------------------------
TrackInfo track;
::String desc,genre,url,comment;
+ unsigned int ppFlags; //JP-MOD
};
public:
void init();
void initLocal(int numl,int numr,int nums,int uptm,bool,bool,unsigned int,Channel*,unsigned int,unsigned int);
+ void initLocal_pp(bool isStealth, int numClaps); //JP-MOD
XML::Node *createXML();
void writeAtoms(AtomStream &,GnuID &);
Host host;
Host rhost[2];
unsigned int numListeners,numRelays,numHops;
+ int clap_pp; //JP-MOD
unsigned int time,upTime,lastContact;
unsigned int hitID;
GnuID sessionID,chanID;
void clearHits(bool);
int numHits();
int numListeners();
+ int numClaps(); //JP-MOD
int numRelays();
int numFirewalled();
int numTrackers();
int localListeners();
int localRelays();
+ int totalClaps(); //JP-MOD
int totalListeners();
int totalRelays();
::String sourceURL;
bool bump,stayConnected;
+ bool stealth; //JP-MOD
int icyMetaInterval;
unsigned int streamPos;
unsigned int skipCount; //JP-EX
bool readDelay;
+ int overrideMaxRelaysPerChannel; //JP-MOD
+ bool bClap; //JP-MOD
TYPE type;
ChannelSource *sourceData;
type = t;
urls = new ::String[max];
titles = new ::String[max];
+ contacturls = new ::String[max]; //JP-MOD
}
~PlayList()
{
delete [] urls;
delete [] titles;
+ delete [] contacturls; //JP-MOD
}
- void addURL(const char *url, const char *tit)
+ void addURL(const char *url, const char *tit, const char *contacturl/*JP-MOD*/)
{
if (numURLs < maxURLs)
{
urls[numURLs].set(url);
titles[numURLs].set(tit);
+ contacturls[numURLs].set(contacturl); //JP-MOD
numURLs++;
}
}
TYPE type;
int numURLs,maxURLs;
::String *urls,*titles;
+ ::String *contacturls; //JP-MOD
};
// ----------------------------------
,fwState(0)
,lastUpdate(0)
,lastCheckTime(0)
+ ,lastClapped(0) //JP-MOD
,parent(NULL)
{}
virtual ~ChannelStream() {}
int fwState;
unsigned int lastUpdate;
unsigned int lastCheckTime;
+ unsigned int lastClapped; //JP-MOD
Channel *parent;
};
if (str)
{
- int slen = strlen(str);
+ size_t slen = strlen(str);
mem.write((void *)str,slen+1); // string
}else
mem.writeChar(0); // null string
int HTML::getIntVariable(const String &varName,int loop)
{
String val;
+ LOG_DEBUG("AAA %d %d %d %d", val[0], val[1], val[2], val[3]);
MemoryStream mem(val.cstr(),String::MAX_LEN);
writeVariable(mem,varName,loop);
+ LOG_DEBUG("AAA %d %d %d %d", val[0], val[1], val[2], val[3]);
return atoi(val.cstr());
}
// --------------------------------------
writeVariable(mem,varName,loop);
+ String tmp;
+ tmp = varName;
+ LOG_DEBUG("*** %s : %c", tmp.cstr(), val[0]);
+
// integer
if ((val[0] >= '0') && (val[0] <= '9'))
return atoi(val.cstr()) != 0;
{
if (getBoolVariable(var,loop)==varCond)
{
+ LOG_DEBUG("==varCond, loop = %d", loop);
if (readTemplate(in,outp,loop))
readTemplate(in,NULL,loop);
}else{
+ LOG_DEBUG("!=varCond, loop = %d", loop);
if (readTemplate(in,NULL,loop))
readTemplate(in,outp,loop);
}
{
int cnt = getIntVariable(var,loop);
+ LOG_DEBUG("loop_cnt : %s = %d", var.cstr(), cnt);
+
if (cnt)
{
int spos = in.getPosition();
int PCPStream::readPacket(Stream &in,Channel *)
{
BroadcastState bcs;
+ bcs.ttl = 1;
return readPacket(in,bcs);
}
// ------------------------------------------
if (servMgr->autoBumpSkipCount) //JP-EX
{
- if (ch->skipCount > servMgr->autoBumpSkipCount)
+ if ((ch->skipCount > servMgr->autoBumpSkipCount) && !(servMgr->disableAutoBumpIfDirect && ch->sourceHost.tracker)) //JP-MOD
{
LOG_DEBUG("Auto bump");
ch->bump = true;
hit.uphost.port = atom.readInt();
else if (id == PCP_HOST_UPHOST_HOPS)
hit.uphostHops = atom.readInt();
- else
+ else if (id == PCP_HOST_CLAP_PP){ //JP-MOD
+ hit.clap_pp = atom.readInt();
+ if (hit.clap_pp & 1){
+ Channel *c = chanMgr->findChannelByID(chanID);
+ if(c && c->isBroadcasting()){
+ String sjis;
+ sjis = c->info.name;
+ sjis.convertTo(String::T_SJIS);
+ peercastApp->notifyMessage(ServMgr::NT_APPLAUSE, sjis);
+ }
+ }
+ }else
{
LOG_DEBUG("PCP skip: %s,%d,%d",id.getString().str(),c,d);
atom.skip(c,d);
hit.servent_id = bcs.servent_id;
- if (flg){
+ if (flg && (bcs.ttl != 0)){
// LOG_DEBUG("readHostAtoms HITLISTLOCK ON-------------");
chanMgr->hitlistlock.on();
if (hit.recv)
int PCPStream::readBroadcastAtoms(AtomStream &atom,int numc,BroadcastState &bcs)
{
ChanPacket pack;
- int ttl=0;
+ //int ttl=0;
int ver=0;
int ver_vp=0;
GnuID fromID,destID;
if (id == PCP_BCST_TTL)
{
- ttl = atom.readChar()-1;
- patom.writeChar(id,ttl);
-
+ bcs.ttl = atom.readChar()-1;
+ patom.writeChar(id,bcs.ttl);
}else if (id == PCP_BCST_HOPS)
{
bcs.numHops = atom.readChar()+1;
pmem.pos = oldPos;
r = readAtom(patom,bcs);
} else {
- LOG_DEBUG("### Invalid bcst: hops=%d, ver=%d(VP%04d), ttl=%d",
- bcs.numHops,ver,ver_vp,ttl);
- ttl = 0;
+ char tmp[80], tmp2[80], tmp3[80];
+ hit.uphost.toStr(tmp);
+ hit.host.toStr(tmp2);
+ sv->getHost().toStr(tmp3);
+ LOG_DEBUG("### Invalid bcst: hops=%d, l/r = %d/%d, ver=%d(VP%04d), ttl=%d",
+ bcs.numHops,hit.numListeners, hit.numRelays, ver,ver_vp,bcs.ttl);
+ LOG_DEBUG("### %s <- %s <- sv(%s)",
+ tmp2, tmp, tmp3);
+ bcs.ttl = 0;
}
} else {
// copy and process atoms
if (ver_ex_number){
LOG_DEBUG("PCP bcst: group=%d, hops=%d, ver=%d(%c%c%04d), from=%s, dest=%s ttl=%d",
- bcs.group,bcs.numHops,ver,ver_ex_prefix[0],ver_ex_prefix[1],ver_ex_number,fromStr,destStr,ttl);
+ bcs.group,bcs.numHops,ver,ver_ex_prefix[0],ver_ex_prefix[1],ver_ex_number,fromStr,destStr,bcs.ttl);
} else if (ver_vp){
- LOG_DEBUG("PCP bcst: group=%d, hops=%d, ver=%d(VP%04d), from=%s, dest=%s ttl=%d",bcs.group,bcs.numHops,ver,ver_vp,fromStr,destStr,ttl);
+ LOG_DEBUG("PCP bcst: group=%d, hops=%d, ver=%d(VP%04d), from=%s, dest=%s ttl=%d",bcs.group,bcs.numHops,ver,ver_vp,fromStr,destStr,bcs.ttl);
} else {
- LOG_DEBUG("PCP bcst: group=%d, hops=%d, ver=%d, from=%s, dest=%s ttl=%d",bcs.group,bcs.numHops,ver,fromStr,destStr,ttl);
+ LOG_DEBUG("PCP bcst: group=%d, hops=%d, ver=%d, from=%s, dest=%s ttl=%d",bcs.group,bcs.numHops,ver,fromStr,destStr,bcs.ttl);
}
if (fromID.isSet())
return PCP_ERROR_BCST+PCP_ERROR_LOOPBACK;
}
- // broadcast back out if ttl > 0
- if ((ttl>0) && (!bcs.forMe))
- {
- pack.len = pmem.pos;
- pack.type = ChanPacket::T_PCP;
-
- if (bcs.group & (/*PCP_BCST_GROUP_ROOT|*/PCP_BCST_GROUP_TRACKERS|PCP_BCST_GROUP_RELAYS))
+ // broadcast back out if ttl > 0
+ if ((bcs.ttl>0) && (!bcs.forMe))
{
- pack.priority = 11 - bcs.numHops;
- chanMgr->broadcastPacketUp(pack,bcs.chanID,remoteID,destID);
- }
+ pack.len = pmem.pos;
+ pack.type = ChanPacket::T_PCP;
- if (bcs.group & (/*PCP_BCST_GROUP_ROOT|*/PCP_BCST_GROUP_TRACKERS|PCP_BCST_GROUP_RELAYS))
- {
- servMgr->broadcastPacket(pack,bcs.chanID,remoteID,destID,Servent::T_COUT);
- }
+ if (bcs.group & (/*PCP_BCST_GROUP_ROOT|*/PCP_BCST_GROUP_TRACKERS|PCP_BCST_GROUP_RELAYS))
+ {
+ pack.priority = 11 - bcs.numHops;
+ chanMgr->broadcastPacketUp(pack,bcs.chanID,remoteID,destID);
+ }
- if (bcs.group & (PCP_BCST_GROUP_RELAYS|PCP_BCST_GROUP_TRACKERS))
- {
- servMgr->broadcastPacket(pack,bcs.chanID,remoteID,destID,Servent::T_CIN);
- }
+ if (bcs.group & (/*PCP_BCST_GROUP_ROOT|*/PCP_BCST_GROUP_TRACKERS|PCP_BCST_GROUP_RELAYS))
+ {
+ servMgr->broadcastPacket(pack,bcs.chanID,remoteID,destID,Servent::T_COUT);
+ }
- if (bcs.group & (PCP_BCST_GROUP_RELAYS))
- {
- servMgr->broadcastPacket(pack,bcs.chanID,remoteID,destID,Servent::T_RELAY);
- }
+ if (bcs.group & (PCP_BCST_GROUP_RELAYS|PCP_BCST_GROUP_TRACKERS))
+ {
+ servMgr->broadcastPacket(pack,bcs.chanID,remoteID,destID,Servent::T_CIN);
+ }
+ if (bcs.group & (PCP_BCST_GROUP_RELAYS))
+ {
+ servMgr->broadcastPacket(pack,bcs.chanID,remoteID,destID,Servent::T_RELAY);
+ }
-// LOG_DEBUG("ttl=%d",ttl);
- } else {
-// LOG_DEBUG("ttl=%d",ttl);
- }
+ // LOG_DEBUG("ttl=%d",ttl);
+
+ } else {
+ // LOG_DEBUG("ttl=%d",ttl);
+ }
return r;
}
static const ID4 PCP_HOST_VERSION_VP = "vevp";
static const ID4 PCP_HOST_VERSION_EX_PREFIX = "vexp";
static const ID4 PCP_HOST_VERSION_EX_NUMBER = "vexn";
+static const ID4 PCP_HOST_CLAP_PP = "clap"; //JP-MOD
static const ID4 PCP_HOST_FLAGS1 = "flg1";
static const ID4 PCP_HOST_OLDPOS = "oldp";
static const ID4 PCP_HOST_NEWPOS = "newp";
static const ID4 PCP_CHAN_INFO_URL = "url";
static const ID4 PCP_CHAN_INFO_DESC = "desc";
static const ID4 PCP_CHAN_INFO_COMMENT = "cmnt";
+static const ID4 PCP_CHAN_INFO_PPFLAGS = "pflg"; //JP-MOD
static const ID4 PCP_CHAN_TRACK = "trck";
static const ID4 PCP_CHAN_TRACK_TITLE = "titl";
,streamPos(0)
,group(0)
,servent_id(0)
+ ,ttl(0)
{
chanID.clear();
bcID.clear();
unsigned int streamPos;
int group;
int servent_id;
+ int ttl;
};
// ----------------------------------------------
#define new DEBUG_NEW
#endif
-
+#include "version2.h"
// ---------------------------------
// globals
PeercastInstance *peercastInst=NULL;
PeercastApplication *peercastApp=NULL;
+int version_ex = 0;
// ---------------------------------
void APICALL PeercastInstance::init()
#define DEBUG_NEW new(__FILE__, __LINE__)
#define new DEBUG_NEW
#endif
+
+static const int dummy = 0;
}
strcat(buf,h_ip);
char h_name[128];
- if (ClientSocket::getHostname(h_name,h.ip))
+ if (ClientSocket::getHostname(h_name,sizeof(h_name),h.ip)) //JP-MOD(BOF\91Î\8dô)
{
strcat(buf,"[");
strcat(buf,h_name);
{
if (str)
{
- int slen = strlen(str);
- for(int i=0; i<slen; i++)
+ size_t slen = strlen(str);
+ for(size_t i=0; i<slen; i++)
if (str[i]=='&') str[i] = 0;
}
}
if (pwdArg && songArg)
{
- int i;
- int slen = strlen(fn);
+ size_t i;
+ size_t slen = strlen(fn);
for(i=0; i<slen; i++)
if (fn[i]=='&') fn[i] = 0;
int newPort=servMgr->serverHost.port;
int enableGetName = 0;
int allowConnectPCST = 0;
+ int disableAutoBumpIfDirect = 0; //JP-MOD
+ int asxDetailedMode = 0; //JP-MOD
char *cp = cmd;
while (cp=nextCGIarg(cp,curr,arg))
{
+ LOG_DEBUG("ARG: %s = %s", curr, arg);
+
// server
if (strcmp(curr,"serveractive")==0)
servMgr->autoServe = getCGIargBOOL(arg);
{
servMgr->numFilters++;
servMgr->filters[servMgr->numFilters].init(); // clear new entry
+ LOG_DEBUG("numFilters = %d", servMgr->numFilters);
}
}else if (strncmp(fs,"bn",2)==0)
else if (strcmp(curr, "maxRelaysIndexTxt") ==0) // for PCRaw (relay)
servMgr->maxRelaysIndexTxt = getCGIargINT(arg);
+ else if (strcmp(curr, "disableAutoBumpIfDirect") ==0) //JP-MOD
+ disableAutoBumpIfDirect = atoi(arg) ? 1 : 0;
+ else if (strcmp(curr, "asxDetailedMode") ==0) //JP-MOD
+ asxDetailedMode = getCGIargINT(arg);
}
servMgr->allowServer2 = allowServer2;
servMgr->enableGetName = enableGetName;
servMgr->allowConnectPCST = allowConnectPCST;
+ servMgr->disableAutoBumpIfDirect = disableAutoBumpIfDirect; //JP-MOD
+ servMgr->asxDetailedMode = asxDetailedMode; //JP-MOD
if (!(servMgr->allowServer1 & ALLOW_HTML) && !(servMgr->allowServer2 & ALLOW_HTML))
servMgr->allowServer1 |= ALLOW_HTML;
}else if (strcmp(curr,"type")==0)
{
info.contentType = ChanInfo::getTypeFromStr(arg);
+ }else if (strcmp(curr,"bcstClap")==0) //JP-MOD
+ {
+ info.ppFlags |= ServMgr::bcstClap;
}
}
Channel *c = chanMgr->findChannelByName(chname.cstr());
if (c && (c->isActive()) && (c->status == Channel::S_BROADCASTING)){
ChanInfo newInfo = c->info;
+ newInfo.ppFlags = ServMgr::bcstNone; //JP-MOD
while (cmd=nextCGIarg(cmd,curr,arg))
{
String chmeta;
newInfo.genre = chmeta.cstr();
else if (strcmp(curr,"comment")==0)
newInfo.comment = chmeta.cstr();
+ else if (strcmp(curr,"bcstClap")==0) //JP-MOD
+ newInfo.ppFlags |= ServMgr::bcstClap;
else if (strcmp(curr,"t_contact")==0)
newInfo.track.contact = chmeta.cstr();
else if (strcmp(curr,"t_title")==0)
chanLog="";
maxRelaysIndexTxt = 1; // for PCRaw (relay)
+
+ { //JP-MOD
+#ifdef WIN32
+ guiSimpleChannelList = false;
+ guiSimpleConnectionList = false;
+ guiTopMost = false;
+
+ guiChanListDisplays = 10;
+ guiConnListDisplays = 10;
+
+ guiTitleModify = false;
+ guiTitleModifyNormal = "PeerCast \8eó\90M:%rx.kbits.1%kbps \91\97\90M:%tx.kbits.1%kbps";
+ guiTitleModifyMinimized = "R:%rx.kbytes%KB/s T:%tx.kbytes%KB/s";
+
+ guiAntennaNotifyIcon = false;
+#endif
+
+ disableAutoBumpIfDirect = 1;
+ asxDetailedMode = 1;
+ }
}
// -----------------------------------
BCID *ServMgr::findValidBCID(int index)
numFilters++;
+ LOG_DEBUG("numFilters = %d", numFilters);
}
// -----------------------------------
iniFile.writeIntValue("maxRelaysIndexTxt", servMgr->maxRelaysIndexTxt); // for PCRaw (relay)
+ { //JP-MOD
+ iniFile.writeIntValue("disableAutoBumpIfDirect",servMgr->disableAutoBumpIfDirect);
+ iniFile.writeIntValue("asxDetailedMode",servMgr->asxDetailedMode);
+
+ iniFile.writeSection("PP");
+#ifdef WIN32
+ iniFile.writeBoolValue("ppClapSound", servMgr->ppClapSound);
+ iniFile.writeStrValue("ppClapSoundPath", servMgr->ppClapSoundPath.cstr());
+#endif
+ }
+
//JP-EX
iniFile.writeSection("Windows");
iniFile.writeBoolValue("getModulePath",servMgr->getModulePath);
iniFile.writeIntValue("guiRight", winPlace.rcNormalPosition.right);
}
+ { //JP-MOD
+ iniFile.writeBoolValue("guiSimpleChannelList", servMgr->guiSimpleChannelList);
+ iniFile.writeBoolValue("guiSimpleConnectionList", servMgr->guiSimpleConnectionList);
+ iniFile.writeBoolValue("guiTopMost", servMgr->guiTopMost);
+
+ iniFile.writeIntValue("guiChanListDisplays", servMgr->guiChanListDisplays);
+ iniFile.writeIntValue("guiConnListDisplays", servMgr->guiConnListDisplays);
+
+ iniFile.writeBoolValue("guiTitleModify", servMgr->guiTitleModify);
+ iniFile.writeStrValue("guiTitleModifyNormal", servMgr->guiTitleModifyNormal.cstr());
+ iniFile.writeStrValue("guiTitleModifyMinimized", servMgr->guiTitleModifyMinimized.cstr());
+
+ iniFile.writeBoolValue("guiAntennaNotifyIcon", servMgr->guiAntennaNotifyIcon);
+ }
+
iniFile.writeBoolValue("topmostGui", servMgr->topmostGui);
iniFile.writeBoolValue("startWithGui", servMgr->startWithGui);
#endif
iniFile.writeBoolValue("PeerCast",notifyMask&NT_PEERCAST);
iniFile.writeBoolValue("Broadcasters",notifyMask&NT_BROADCASTERS);
iniFile.writeBoolValue("TrackInfo",notifyMask&NT_TRACKINFO);
+ iniFile.writeBoolValue("Applause",notifyMask&NT_APPLAUSE); //JP-MOD
iniFile.writeLine("[End]");
else if (iniFile.isName("maxRelaysIndexTxt")) // for PCRaw (relay)
servMgr->maxRelaysIndexTxt = iniFile.getIntValue();
+ //JP-MOD
+ else if (iniFile.isName("disableAutoBumpIfDirect"))
+ servMgr->disableAutoBumpIfDirect = iniFile.getIntValue();
+ else if (iniFile.isName("asxDetailedMode"))
+ servMgr->asxDetailedMode = iniFile.getIntValue();
+
+#ifdef WIN32
+ else if (iniFile.isName("ppClapSound"))
+ servMgr->ppClapSound = iniFile.getBoolValue();
+ else if (iniFile.isName("ppClapSoundPath"))
+ servMgr->ppClapSoundPath.set(iniFile.getStrValue(),String::T_ASCII);
+#endif
+
//JP-Windows
else if (iniFile.isName("getModulePath"))
servMgr->getModulePath = iniFile.getBoolValue();
if (servMgr->saveGuiPos){
guiFlg = true;
}
- }
+ }else if (iniFile.isName("guiSimpleChannelList")) //JP-MOD
+ servMgr->guiSimpleChannelList = iniFile.getBoolValue();
+ else if (iniFile.isName("guiSimpleConnectionList")) //JP-MOD
+ servMgr->guiSimpleConnectionList = iniFile.getBoolValue();
+ else if (iniFile.isName("guiTopMost")) //JP-MOD
+ servMgr->guiTopMost = iniFile.getBoolValue();
+ else if (iniFile.isName("guiChanListDisplays")) //JP-MOD
+ servMgr->guiChanListDisplays = iniFile.getIntValue();
+ else if (iniFile.isName("guiConnListDisplays")) //JP-MOD
+ servMgr->guiConnListDisplays = iniFile.getIntValue();
+ else if (iniFile.isName("guiTitleModify")) //JP-MOD
+ servMgr->guiTitleModify = iniFile.getBoolValue();
+ else if (iniFile.isName("guiTitleModifyNormal")) //JP-MOD
+ servMgr->guiTitleModifyNormal.set(iniFile.getStrValue(),String::T_ASCII);
+ else if (iniFile.isName("guiTitleModifyMinimized")) //JP-MOD
+ servMgr->guiTitleModifyMinimized.set(iniFile.getStrValue(),String::T_ASCII);
+ else if (iniFile.isName("guiAntennaNotifyIcon")) //JP-MOD
+ servMgr->guiAntennaNotifyIcon = iniFile.getBoolValue();
else if (iniFile.isName("topmostGui"))
{
if (numFilters < (MAX_FILTERS-1))
numFilters++;
+ LOG_DEBUG("*** numFilters = %d", numFilters);
}
else if (iniFile.isName("[Notify]"))
{
notifyMask |= iniFile.getBoolValue()?NT_BROADCASTERS:0;
else if (iniFile.isName("TrackInfo"))
notifyMask |= iniFile.getBoolValue()?NT_TRACKINFO:0;
+ else if (iniFile.isName("Applause")) //JP-MOD
+ notifyMask |= iniFile.getBoolValue()?NT_APPLAUSE:0;
}
}
if (!numFilters)
setFilterDefaults();
+ LOG_DEBUG("numFilters = %d", numFilters);
}
// --------------------------------------------------
#else
priv = "";
#endif
-#ifdef VERSION_EX
- LOG_DEBUG("Peercast %s, %s %s",PCX_VERSTRING_EX,peercastApp->getClientTypeOS(),priv);
-#else
- LOG_DEBUG("Peercast %s, %s %s",PCX_VERSTRING,peercastApp->getClientTypeOS(),priv);
-#endif
+ if (version_ex)
+ {
+ LOG_DEBUG("Peercast %s, %s %s",PCX_VERSTRING_EX,peercastApp->getClientTypeOS(),priv);
+ } else
+ {
+ LOG_DEBUG("Peercast %s, %s %s",PCX_VERSTRING,peercastApp->getClientTypeOS(),priv);
+ }
sessionID.toStr(idStr);
LOG_DEBUG("SessionID: %s",idStr);
atom.writeBytes(PCP_BCST_FROM,servMgr->sessionID.id,16);
atom.writeInt(PCP_BCST_VERSION,PCP_CLIENT_VERSION);
atom.writeInt(PCP_BCST_VERSION_VP,PCP_CLIENT_VERSION_VP);
-#ifdef VERSION_EX
- atom.writeBytes(PCP_BCST_VERSION_EX_PREFIX,PCP_CLIENT_VERSION_EX_PREFIX,2);
- atom.writeShort(PCP_BCST_VERSION_EX_NUMBER,PCP_CLIENT_VERSION_EX_NUMBER);
-#endif
+ if (version_ex)
+ {
+ atom.writeBytes(PCP_BCST_VERSION_EX_PREFIX,PCP_CLIENT_VERSION_EX_PREFIX,2);
+ atom.writeShort(PCP_BCST_VERSION_EX_NUMBER,PCP_CLIENT_VERSION_EX_NUMBER);
+ }
atom.writeParent(PCP_PUSH,3);
atom.writeInt(PCP_PUSH_IP,to.ip);
atom.writeShort(PCP_PUSH_PORT,to.port);
ChanPacket pack;
MemoryStream mem(pack.data,sizeof(pack.data));
AtomStream atom(mem);
-#ifndef VERSION_EX
+ if (version_ex == 0)
+ {
atom.writeParent(PCP_BCST,7);
-#else
+ } else
+ {
atom.writeParent(PCP_BCST,9);
-#endif
- atom.writeChar(PCP_BCST_GROUP,PCP_BCST_GROUP_TRACKERS);
- atom.writeChar(PCP_BCST_HOPS,0);
- atom.writeChar(PCP_BCST_TTL,7);
- atom.writeBytes(PCP_BCST_FROM,sessionID.id,16);
- atom.writeInt(PCP_BCST_VERSION,PCP_CLIENT_VERSION);
- atom.writeInt(PCP_BCST_VERSION_VP,PCP_CLIENT_VERSION_VP);
-#ifdef VERSION_EX
+ }
+ atom.writeChar(PCP_BCST_GROUP,PCP_BCST_GROUP_TRACKERS);
+ atom.writeChar(PCP_BCST_HOPS,0);
+ atom.writeChar(PCP_BCST_TTL,7);
+ atom.writeBytes(PCP_BCST_FROM,sessionID.id,16);
+ atom.writeInt(PCP_BCST_VERSION,PCP_CLIENT_VERSION);
+ atom.writeInt(PCP_BCST_VERSION_VP,PCP_CLIENT_VERSION_VP);
+ if (version_ex)
+ {
atom.writeBytes(PCP_BCST_VERSION_EX_PREFIX,PCP_CLIENT_VERSION_EX_PREFIX,2);
atom.writeShort(PCP_BCST_VERSION_EX_NUMBER,PCP_CLIENT_VERSION_EX_NUMBER);
-#endif
- writeRootAtoms(atom,getUpdate);
+ }
+ writeRootAtoms(atom,getUpdate);
mem.len = mem.pos;
mem.rewind();
String str;
if (var == "version")
-#ifdef VERSION_EX
- strcpy(buf,PCX_VERSTRING_EX);
-#else
- strcpy(buf,PCX_VERSTRING);
-#endif
+ if (version_ex)
+ {
+ strcpy(buf,PCX_VERSTRING_EX);
+ } else
+ {
+ strcpy(buf,PCX_VERSTRING);
+ }
else if (var == "uptime")
{
str.setFromStopwatch(getUptime());
sprintf(buf,"%d",getFirewall()==FW_UNKNOWN?0:1);
else if (var == "rootMsg")
strcpy(buf,rootMsg);
- else if (var == "isRoot")
+ else if (var == "isRoot"){
+ LOG_DEBUG("isRoot = %d", isRoot);
sprintf(buf,"%d",isRoot?1:0);
+ }
else if (var == "isPrivate")
sprintf(buf,"%d",(PCP_BROADCAST_FLAGS&1)?1:0);
else if (var == "forceYP")
sprintf(buf,"%d",maxControl);
else if (var == "maxServIn")
sprintf(buf,"%d",maxServIn);
- else if (var == "numFilters")
+ else if (var == "numFilters") {
+ LOG_DEBUG("*-* numFilters = %d", numFilters);
sprintf(buf,"%d",numFilters+1);
+ }
else if (var == "maxPGNUIn")
sprintf(buf,"%d",maxGnuIncoming);
else if (var == "minPGNUIn")
else if (var == "enableGetName")
strcpy(buf, (enableGetName == 1)? "1":"0");
+ //JP-MOD
+ else if (var == "disableAutoBumpIfDirect")
+ strcpy(buf, (disableAutoBumpIfDirect == 1) ? "1":"0");
+ else if (var.startsWith("asxDetailedMode"))
+ {
+ if (var == "asxDetailedMode.0")
+ strcpy(buf, (asxDetailedMode == 0) ? "1":"0");
+ else if (var == "asxDetailedMode.1")
+ strcpy(buf, (asxDetailedMode == 1) ? "1":"0");
+ else if (var == "asxDetailedMode.2")
+ strcpy(buf, (asxDetailedMode == 2) ? "1":"0");
+ }
+
// VP-EX
else if (var == "ypAddress2")
strcpy(buf,rootHost2.cstr());
NT_UPGRADE = 0x0001,
NT_PEERCAST = 0x0002,
NT_BROADCASTERS = 0x0004,
- NT_TRACKINFO = 0x0008
+ NT_TRACKINFO = 0x0008,
+ NT_APPLAUSE = 0x0010 //JP-MOD
};
enum FW_STATE
int maxRelaysIndexTxt; // for PCRaw (relay)
+#ifdef WIN32 //JP-MOD
+ bool guiSimpleChannelList;
+ bool guiSimpleConnectionList;
+ bool guiTopMost;
+
+ int guiChanListDisplays;
+ int guiConnListDisplays;
+ bool guiTitleModify;
+ String guiTitleModifyNormal;
+ String guiTitleModifyMinimized;
+
+ bool guiAntennaNotifyIcon;
+
+ bool ppClapSound;
+ String ppClapSoundPath;
+#endif
+
+ int disableAutoBumpIfDirect;
+ int asxDetailedMode;
+
+ enum PPBCSTFLAG //JP-MOD
+ {
+ bcstNone = 0x00000000,
+ bcstClap = 0x00000001
+ };
+
private:
FW_STATE firewalled;
};
static unsigned int getIP(char *);
- static bool getHostname(char *,unsigned int);
+ static bool getHostname(char *,size_t,unsigned int); //JP-MOD
virtual bool eof()
{
{
lock.on();
- unsigned int len = strlen(str);
+ size_t len = strlen(str);
int cnt=0;
while (len)
{
- unsigned int rlen = len;
+ size_t rlen = len;
if (rlen > (lineLen-1))
rlen = lineLen-1;
// set from null terminated string, remove first/last chars
void setUnquote(const char *p, TYPE t=T_ASCII)
{
- int slen = strlen(p);
+ size_t slen = strlen(p);
if (slen > 2)
{
if (slen >= MAX_LEN) slen = MAX_LEN;
void clear()
{
+ memset(data, 0, MAX_LEN);
data[0]=0;
type = T_UNKNOWN;
}
typedef __int64 int64_t;
+#ifndef _UINTPTR_T_DEFINED
+typedef unsigned int uintptr_t;
+#endif
// ------------------------------------
class WEvent
// ------------------------------------
typedef int (WINAPI *THREAD_FUNC)(ThreadInfo *);
-typedef unsigned int THREAD_HANDLE;
+typedef uintptr_t THREAD_HANDLE;
#define THREAD_PROC int WINAPI
#define vsnprintf _vsnprintf
#endif
// ------------------------------------------------
static const int PCP_CLIENT_VERSION = 1218;
-static const int PCP_CLIENT_VERSION_VP = 26;
+static const int PCP_CLIENT_VERSION_VP = 27;
static const int PCP_ROOT_VERSION = 1218;
static const int PCP_CLIENT_MINVERSION = 1200;
static const char *PCX_AGENT = "PeerCast/0.1218";
static const char *PCX_AGENTJP = "PeerCast/0.1218-J";
-static const char *PCX_AGENTVP = "PeerCast/0.1218(VP0026)";
-static const char *PCX_VERSTRING = "v0.1218(VP0026)";
+static const char *PCX_AGENTVP = "PeerCast/0.1218(VP0027)";
+static const char *PCX_VERSTRING = "v0.1218(VP0027)";
+
+extern int version_ex; // PP\94Å\8ag\92£\8b@\94\\97L\8cø\89»\83t\83\89\83O(\82½\82Ô\82ñ)
#if 1 /* for VP extend version */
-#define VERSION_EX 1
+//#define VERSION_EX 1
static const char *PCP_CLIENT_VERSION_EX_PREFIX = "IM"; // 2bytes only
static const int PCP_CLIENT_VERSION_EX_NUMBER = 27;
-static const char *PCX_AGENTEX = "PeerCast/0.1218(IM0027)";
-static const char *PCX_VERSTRING_EX = "v0.1218(IM0027)";
+static const char *PCX_AGENTEX = "PeerCast/0.1218(IM0027-2)";
+static const char *PCX_VERSTRING_EX = "v0.1218(IM0027-2)";
#endif
// ------------------------------------------------
// ----------------------------------
char *XML::Node::findAttr(const char *name)
{
- int nlen = strlen(name);
+ size_t nlen = strlen(name);
for(int i=1; i<numAttr; i++)
{
char *an = getAttrName(i);
#include <windows.h>
#include <stdio.h>
#include "wsocket.h"
-#include "stats.h"
+#include "..\common\stats.h"
#ifdef _DEBUG
#include "chkMemoryLeak.h"
#define DEBUG_NEW new(__FILE__, __LINE__)
}
// --------------------------------------------------
-bool ClientSocket::getHostname(char *str,unsigned int ip)
+bool ClientSocket::getHostname(char *str,size_t size,unsigned int ip) //JP-MOD
{
+ if(size == 0)
+ return false;
+
HOSTENT *he;
ip = htonl(ip);
if (he)
{
- strcpy(str,he->h_name);
+ LOG_DEBUG("getHostname: %d.%d.%d.%d -> %s", ((BYTE*)&ip)[0], ((BYTE*)&ip)[1], ((BYTE*)&ip)[2], ((BYTE*)&ip)[3], he->h_name);
+ strncpy(str,he->h_name,size-1);
+ str[size-1] = '\0';
return true;
}else
return false;
int fromSize = sizeof(sockaddr_in);
sockaddr_in from;
- int conSock = ::accept(sockNum,(sockaddr *)&from,&fromSize);
+ SOCKET conSock = ::accept(sockNum,(sockaddr *)&from,&fromSize);
if (conSock == INVALID_SOCKET)
#define _WSOCKET_H
#include <windows.h>
-#include "socket.h"
+#include "..\common\socket.h"
//#include "winsock2.h"
void checkBuffering(bool, bool);
unsigned int writeCnt;
- unsigned int sockNum;
+ SOCKET sockNum;
struct sockaddr_in remoteAddr;
enum {RBSIZE = 8192};
#include <process.h>
#include <windows.h>
#include <time.h>
-#include "win32/wsys.h"
-#include "win32/wsocket.h"
-#include "stats.h"
-#include "peercast.h"
+#include "wsys.h"
+#include "wsocket.h"
+#include "..\common\stats.h"
+#include "..\common\peercast.h"
#include <sys/timeb.h>
#include <time.h>
#include "shellapi.h"
{
time_t ltime;
time( <ime );
- return ltime;
+ return (unsigned)ltime;
}
// ---------------------------------
#define _WSYS_H
// ------------------------------------
#include <windows.h>
-#include "socket.h"
-#include "sys.h"
+#include "..\common\socket.h"
+#include "..\common\sys.h"
// ------------------------------------
class WSys : public Sys
hInst = hInstance;
+ version_ex = 0; // PP\94Å\8ag\92£\8b@\94\\82ð\96³\8cø\82É
+
iniFileName.set(".\\peercast.ini");
WIN32_FIND_DATA fd; //JP-EX
case WM_INITDIALOG:
//SendDlgItemMessage(hDlg,IDC_ABOUTVER,WM_SETTEXT,0,(LONG)PCX_AGENT);
// SendDlgItemMessage(hDlg,IDC_ABOUTVER,WM_SETTEXT,0,(LONG)PCX_AGENTJP);
-#ifdef VERSION_EX
- SendDlgItemMessage(hDlg,IDC_ABOUTVER,WM_SETTEXT,0,(LONG)PCX_AGENTEX);
-#else
- SendDlgItemMessage(hDlg,IDC_ABOUTVER,WM_SETTEXT,0,(LONG)PCX_AGENTVP);
-#endif
+ if (version_ex)
+ {
+ SendDlgItemMessage(hDlg,IDC_ABOUTVER,WM_SETTEXT,0,(LONG)PCX_AGENTEX);
+ } else
+ {
+ SendDlgItemMessage(hDlg,IDC_ABOUTVER,WM_SETTEXT,0,(LONG)PCX_AGENTVP);
+ }
+
return TRUE;
case WM_COMMAND: