/* * This method checks to see if the two CKIRCProtocols are equal to * one another based on the values they represent and *not* on the * actual pointers themselves. If they are equal, then this method * returns true, otherwise it returns false. */ bool CKIRCProtocol::operator==( const CKIRCProtocol & anOther ) const { bool equal = true; if ((getHostname() != anOther.getHostname()) || (getPort() != anOther.getPort()) || (mCommPort != anOther.mCommPort) || (isLoggedIn() != anOther.isLoggedIn()) || (getPassword() != anOther.getPassword()) || (getNickname() != anOther.getNickname()) || (getUserHost() != anOther.getUserHost()) || (getUserServer() != anOther.getUserServer()) || (getRealName() != anOther.getRealName()) || (mChannelList != anOther.mChannelList) || (mResponders != anOther.mResponders)) { equal = false; } return equal; }
/* * Because there are times when it's useful to have a nice * human-readable form of the contents of this instance. Most of the * time this means that it's used for debugging, but it could be used * for just about anything. In these cases, it's nice not to have to * worry about the ownership of the representation, so this returns * a CKString. */ CKString CKIRCProtocol::toString() const { CKString retval = "< IRC Host="; retval += getHostname(); retval += ", "; retval += " IRC Port="; retval += getPort(); retval += ", "; retval += " CommPort="; retval += mCommPort.toString(); retval += ", "; retval += " isLoggedIn? "; retval += (isLoggedIn() ? "Yes" : "No"); retval += ", "; retval += " Password="******" Nickname="; retval += getNickname(); retval += " UserHost="; retval += getUserHost(); retval += " UserServer="; retval += getUserServer(); retval += " RealName="; retval += getRealName(); retval += " ChannelList: ["; CKStringNode *i = NULL; for (i = mChannelList.getHead(); i != NULL; i = i->getNext()) { if (i->getPrev() != NULL) { retval += ", "; } retval += (*i); } retval += "]>\n"; return retval; }
void dlgcd_refresh(void *mp1, void **mp2) { int i; char drive[4]; HWND hwnd = (HWND) mp1; cdDrive = new CD_drive; getText(WinWindowFromID(hwnd, CB_DRIVE), CBID_EDIT, drive, sizeof(drive)); drive[1] = ':'; drive[2] = 0; /* find info on CD tracks */ if(!cdDrive->open(drive) || !cdDrive->readCDInfo() || !cdDrive->fillTrackInfo() || !cdDrive->close() ) { delete cdDrive; cdDrive = NULL; return; } if(getCheck(hwnd, CB_USECDDB)) { char server[512]; BOOL success = FALSE; ULONG serverType; SHORT index = LIT_FIRST; cddbSocket = new CDDB_socket; *mp2 = cddbSocket; /* to be able to cancel */ do { serverType = getNextCDDBServer(server,sizeof(server),&index); if(serverType != NOSERVER) { if(serverType == CDDB) { updateStatus("Contacting: %s", server); char host[512]=""; int port=8880; sscanf(server,"%[^:\n\r]:%d",host,&port); if(host[0]) cddbSocket->tcpip_socket::connect(host,port); } else { char host[512], path[512], proxy[512], *slash = NULL, *http = NULL; http = strstr(server,"http://"); if(http) slash = strchr(http+7,'/'); if(slash) { strncpy(host,server,slash-server); strcpy(path,slash); getProxy(proxy,sizeof(proxy)); if(*proxy) updateStatus("Contacting: %s", proxy); else updateStatus("Contacting: %s", server); cddbSocket->connect(host,proxy,path); } else updateError("Invalid URL: %s", server); } if(!cddbSocket->isOnline()) { if(cddbSocket->getSocketError() == SOCEINTR) goto end; else continue; } updateStatus("Looking at CDDB Server Banner at %s", server); if(!cddbSocket->banner_req()) { if(cddbSocket->getSocketError() == SOCEINTR) goto end; else continue; } updateStatus("Handshaking with CDDB Server %s", server); char user[128]="",host[128]=""; getUserHost(user,sizeof(user),host,sizeof(host)); if(!cddbSocket->handshake_req(user,host)) { if(cddbSocket->getSocketError() == SOCEINTR) goto end; else continue; } updateStatus("Looking for CD information on %s", server); int rc = cddbSocket->query_req(cdDrive, &queryData); if(!rc) { if(cddbSocket->getSocketError() == SOCEINTR) goto end; else continue; } else if(rc == -1) continue; /* no match for this server */ else if(rc == COMMAND_MORE) { CDDBQUERY_DATA *matches = (CDDBQUERY_DATA *) malloc(sizeof(CDDBQUERY_DATA)); int i = 0; while(cddbSocket->get_query_req(&matches[i])) { i++; matches = (CDDBQUERY_DATA *) realloc(matches, (i+1)*sizeof(CDDBQUERY_DATA)); } memset(&matches[i],0,sizeof(matches[i])); /* don't try to open a window in this thread */ WinSendMsg(hwnd,CDDB_FUZZYMATCH,matches,&queryData); free(matches); } /* else there is only one match */ if(queryData.discid) { updateStatus("Requesting CD information from %s", server); if(!cddbSocket->read_req(queryData.category, queryData.discid)) { if(cddbSocket->getSocketError() == SOCEINTR) goto end; else continue; } else success = TRUE; } } } while(serverType != NOSERVER && !success); end: if(!success) { delete cddbSocket; cddbSocket = NULL; } updateStatus(""); } return; }