NYBOT::NYBOT () { pluginName = "NYBOT"; helpFile = "nybot.html"; cancelFlag = FALSE; connect(this, SIGNAL(signalGetFileDone(bool)), this, SLOT(fileDone(bool))); connect(this, SIGNAL(signalTimeout()), this, SLOT(timeoutError())); buildGui(); loadSettings(); qInitNetworkProtocols(); resize(400, 400); }
int main( int argc, char **argv ) { QApplication a( argc, argv ); qInitNetworkProtocols(); QNetworkProtocol::registerNetworkProtocol( "http", new QNetworkProtocolFactory<Http> ); QNetworkProtocol::registerNetworkProtocol( "nntp", new QNetworkProtocolFactory<Nntp> ); View v; v.resize( 600, 600 ); v.setCaption("Qt Example - Network Protocols"); v.show(); a.setMainWidget( &v ); return a.exec(); }
void ktvschedule::correspondChannels() { // clears all Columns before creating new ones t_TVGrid->removeAllColumns(); Channels.clear(); // qInitNetworkProtocols (); KStandardDirs *dirs = new KStandardDirs(); QString home = dirs->localkdedir () + "/share/apps/ktvschedule/"; QUrlOperator *urlOp = new QUrlOperator; // //Stats XML parsing QDomElement docElement = TvXML.documentElement(); QDomNode node = docElement.firstChild(); while( !node.isNull() ) { QDomNode subnode=node.firstChild(); QDomElement node_element=node.toElement(); /////////////////////////// //If it is a channel, load channel name and Id if (node_element.tagName()=="channel") { ChannelNameIcon chanNameandIcon; bool Found = FALSE; while (!subnode.isNull()) { QDomElement subnode_element=subnode.toElement(); if (subnode_element.tagName()=="display-name") { if (!Found) { chanNameandIcon.ChannelName = subnode_element.text(); Found = TRUE; } //in fact some XML guides have many channel names. As from xmltv display names are : List the most canonical / common ones first and the most obscure names last. So we can stop. } if (subnode_element.tagName()=="icon") { chanNameandIcon.ChannelIcon = subnode_element.attribute("src",""); // if the icon is on a remote location, try to fetch it localy if (chanNameandIcon.ChannelIcon.contains("http://")!=0) { // if file does not exist localy, then download it if (!QFile::exists(home + chanNameandIcon.ChannelIcon.section('/',-1) ) ) { urlOp->copy(chanNameandIcon.ChannelIcon, home); // donwload pixmap } // Ok, we are going to save in the config file the url of the pics. It will be used in the channels to download missing pics. QString temp = chanNameandIcon.ChannelIcon.section('/',-1); // We need a temp string Config().picURL = chanNameandIcon.ChannelIcon.remove ( temp ); // Change the location of the pixmap chanNameandIcon.ChannelIcon = home + temp; } else if (chanNameandIcon.ChannelIcon.contains("file://")!=0) { // We create a temp string in order to config the picURL. Otherwise it removes usefull info from the channelIcon QString temp = chanNameandIcon.ChannelIcon; Config().picURL = temp.remove ( temp.section('/',-1) ); QRegExp rx("^[0-9]{1,2}"); QString dest=home + chanNameandIcon.ChannelName.lower().remove(" ").remove(rx)+"."+chanNameandIcon.ChannelIcon.right(3); if (!QFile::exists(dest)) { urlOp->copy(chanNameandIcon.ChannelIcon,dest,FALSE,FALSE); } // Change the location of the pixmap chanNameandIcon.ChannelIcon = dest; } else { qDebug("Pict is of unknown type"); } } subnode=subnode.nextSibling(); } Channels[node_element.attribute("id","")]=chanNameandIcon; } else { // NxTvEPG have another field before the channels (about field). Do not stop if (node_element.tagName()!="about") { break; //no need to continue } } node=node.nextSibling(); } // Creates collumns in the TvGrid. The QMap Channel has the channel name and id t_TVGrid->CreateColumns(Channels); }