void CDDBSetup::getData(QStrList& _serverlist, QStrList& _submitlist, QString& _basedir, QString& _submitaddress, QString& _current_server, bool& remote_enabled, bool& http_proxy_enabled, QString &http_proxy_host, int &http_proxy_port) { uint i; _serverlist.clear(); _submitlist.clear(); for(i = 0; i < server_listbox->count();i++){ _serverlist.append(server_listbox->text(i)); } for(i = 0; i < submission_listbox->count(); i++){ _submitlist.append(submission_listbox->text(i)); } _basedir = basedirstring.copy(); _submitaddress = submitaddressstring.copy(); _current_server = current_server_string.copy(); remote_enabled = remote_cddb_cb->isChecked(); http_proxy_enabled = cddb_http_cb->isChecked(); http_proxy_host = proxy_host_ef->text(); http_proxy_port = atoi(proxy_port_ef->text()); }
int readListConf ( KConfig *conf, QString key, QStrList &list ) { if( !conf->hasKey( key ) ) { // debug("readListConf:: key does not exist"); return 0; } QString str_list, value; str_list = conf->readEntry(key); if(str_list.isEmpty()) { // debug("readListConf:: list is empty"); return 0; } list.clear(); int i; int len = str_list.length(); for( i = 0; i < len; i++ ) { if( str_list[i] != ',' && str_list[i] != '\\' ) { value += str_list[i]; continue; } if( str_list[i] == '\\' ) { i++; value += str_list[i]; continue; } list.append(value); value.truncate(0); } list.append(value); }
/*! Decodes URLs from \a e, placing the result in \a l (which is first cleared). Returns TRUE if the event contained a valid list of URLs. */ bool QUrlDrag::decode( QDropEvent* e, QStrList& l ) { QByteArray payload = e->data( "url/url" ); if ( payload.size() ) { e->accept(); l.clear(); l.setAutoDelete(TRUE); uint c=0; char* d = payload.data(); while (c < payload.size()) { uint f = c; while (c < payload.size() && d[c]) c++; if ( c < payload.size() ) { l.append( d+f ); c++; } else { QString s(d+f,c-f+1); l.append( s ); } } return TRUE; } return FALSE; }
/*! Decodes URIs from \a e, placing the result in \a l (which is first cleared). Returns TRUE if the event contained a valid list of URIs. */ bool QUriDrag::decode( const QMimeSource* e, QStrList& l ) { QByteArray payload = e->encodedData( "text/uri-list" ); if ( payload.size() ) { l.clear(); l.setAutoDelete(TRUE); uint c=0; char* d = payload.data(); while (c < payload.size() && d[c]) { uint f = c; // Find line end while (c < payload.size() && d[c] && d[c]!='\r' && d[c] != '\n') c++; QCString s(d+f,c-f+1); if ( s[0] != '#' ) // non-comment? l.append( s ); // Skip junk while (c < payload.size() && d[c] && (d[c]=='\n' || d[c]=='\r')) c++; } return TRUE; } return FALSE; }
bool cddb_playlist_decode(QStrList& list, QString& str){ bool isok = true; int pos1, pos2; pos1 = 0; pos2 = 0; list.clear(); while((pos2 = str.find(",",pos1,true)) != -1){ if(pos2 > pos1){ list.append(str.mid(pos1,pos2 - pos1)); } pos1 = pos2 + 1; } if(pos1 <(int) str.length()) list.append(str.mid(pos1,str.length())); QString check; bool ok1; int num; for(uint i = 0; i < list.count(); i++){ check = list.at(i); check = check.stripWhiteSpace(); if(check.isEmpty()){ list.remove(i); i--; continue; } if(check == QString (",")){ list.remove(i); i--; continue; } num = check.toInt(&ok1); if(!ok1 || num < 1){ list.remove(i); i--; isok = false; continue; } list.remove(i); list.insert(i, check); } /* for(uint i = 0; i < list.count(); i++){ printf("playlist %d=%s\n",i,list.at(i)); }*/ return isok; }
/*! Decodes URLs from \a e, converts them to local files if they refer to local files, and places them in \a l (which is first cleared). Returns TRUE if the event contained a valid list of URLs. The list will be empty if no URLs were local files. */ bool QUrlDrag::decodeLocalFiles( QDropEvent* e, QStrList& l ) { QStrList u; if ( !decode( e, u ) ) return FALSE; l.clear(); l.setAutoDelete(TRUE); for (const char* s=u.first(); s; s=u.next()) { QString lf = urlToLocalFile(s); if ( !lf.isNull() ) l.append( lf ); } return TRUE; }
bool KHost::ReadConfig() { KConfig *config = ((KConnection*) topLevelWidget())->GetConfig(); QStrList List; const char *Value; int i; if (config == NULL) return FALSE; config->setGroup(KI_SEC_HOSTS); config->readListEntry(KI_ENT_HOSTS,List); hostCombo->insertStrList(&List); List.clear(); config->readListEntry(KI_ENT_PORTS,List); portCombo->insertStrList(&List); Value = config->readEntry(KI_ENT_LAST_HOST); if (Value != NULL && *Value != '\0') for (i = 0; i < hostCombo->count(); i++) if (!strcmp(Value,hostCombo->text(i))) { hostCombo->setCurrentItem(i); break; } Value = config->readEntry(KI_ENT_LAST_PORT); if (Value != NULL && *Value != '\0') for (i = 0; i < portCombo->count(); i++) if (!strcmp(Value,portCombo->text(i))) { portCombo->setCurrentItem(i); break; } hostChanged(0); portChanged(0); return TRUE; }
int KConfigBase::readListEntry(const char *pKey, QStrList &list, char sep) const { if(!hasKey(pKey)) return 0; QCString str_list = readEntryUtf8(pKey); if(str_list.isEmpty()) return 0; list.clear(); QCString value = ""; int len = str_list.length(); for(int i = 0; i < len; i++) { if(str_list[i] != sep && str_list[i] != '\\') { value += str_list[i]; continue; } if(str_list[i] == '\\') { i++; if(i < len) value += str_list[i]; continue; } // if we fell through to here, we are at a separator. Append // contents of value to the list // !!! Sergey A. Sukiyazov <*****@*****.**> !!! // A QStrList may contain values in 8bit locale cpecified // encoding list.append(value); value.truncate(0); } if(str_list[len - 1] != sep || (len > 1 && str_list[len - 2] == '\\')) list.append(value); return list.count(); }
bool KHost::WriteConfig() { KConfig *config = ((KConnection*) topLevelWidget())->GetConfig(); QStrList List; const char *Value; int i; if (config == NULL) return FALSE; hostChanged(0); portChanged(0); config->setGroup(KI_SEC_HOSTS); if ((Value = hostCombo->currentText()) != NULL && *Value != '\0' && List.find(Value) == -1) List.append(Value); for (i = 0; i < hostCombo->count(); i++) if (List.find(hostCombo->text(i)) == -1) List.append(hostCombo->text(i)); config->writeEntry(KI_ENT_HOSTS,List); List.clear(); if ((Value = portCombo->currentText()) != NULL && *Value != '\0' && List.find(Value) == -1) List.append(Value); for (i = 0; i < portCombo->count(); i++) if (List.find(portCombo->text(i)) == -1) List.append(portCombo->text(i)); config->writeEntry(KI_ENT_PORTS,List); config->writeEntry(KI_ENT_LAST_HOST,hostCombo->currentText()); config->writeEntry(KI_ENT_LAST_PORT,portCombo->currentText()); return TRUE; }
bool StringListSelectAndReorderSet::getSelection(QStrList& values) { // ############################################################################ list<int>::iterator pos; list<string>::iterator text; // ----- if(selected.empty()) { return false; } else { values.clear(); for(pos=selected.begin(); pos!=selected.end(); pos++) { text=original.begin(); assert((unsigned)(*pos)<original.size()); advance(text, *pos); values.append((*text).c_str()); } assert(values.count()==selected.size()); return true; } // ############################################################################ }
void cddb_encode(QString& str, QStrList &returnlist){ returnlist.clear(); int pos1 = 0; int pos2 = 0; while((pos2 = str.find("\\",pos1,true)) !=-1){ str.replace(pos2 , 1 , "\\\\"); pos1 = pos2 + 1; } pos1 = 0; pos2 = 0; while((pos2 = str.find("\n",pos1,true)) !=-1){ str.replace(pos2 , 1 , "\\n"); pos1 = pos2 + 1; } pos1 = 0; pos2 = 0; while((pos2 = str.find("\t",pos1,true)) !=-1){ str.replace(pos2 , 1 , "\\t"); pos1 = pos2 + 1; } while(str.length() > 70){ returnlist.append(str.left(70)); str = str.mid(70,str.length()); } returnlist.append(str); }
int main(int argc, char* argv[]) { setuid(getuid()); setgid(getgid()); // drop privileges kimgioRegister(); // add io for additional image formats // deal with shell/command //////////////////////////// int login_shell=0; int welcome=1; char* shell = getenv("SHELL"); char* wname = PACKAGE; if (shell == NULL || *shell == '\0') shell = "/bin/sh"; QString sz = ""; QStrList eargs; eargs.append(shell); setlocale( LC_ALL, "" ); KApplication a(argc, argv, PACKAGE); for (int i = 1; i < argc; i++) { if (!strcmp(argv[i],"-e") && i+1 < argc) // handle command { if (login_shell) fprintf(stderr,"-e excludes -ls.\n"); login_shell = 0; // does not make sense here. eargs.clear(); int j; for (j = 0; j+i+1 < argc; j++) eargs.append( argv[i+j+1] ); break; } if (!strcmp(argv[i],"-vt_sz") && i+1 < argc) sz = argv[++i]; if (!strcmp(argv[i],"-sl") && i+1 < argc) { QString a(argv[++i]); maxHistLines = a.toInt(); } if (!strcmp(argv[i],"-name") && i+1 < argc) wname = argv[++i]; if (!strcmp(argv[i],"-ls") ) login_shell=1; if (!strcmp(argv[i],"-nowelcome")) welcome=0; if (!strcmp(argv[i],"-h")) { usage(); exit(0); } if (!strcmp(argv[i],"-help")) { usage(); exit(0); } if (!strcmp(argv[i],"--help")) { usage(); exit(0); } //FIXME: more: font, menu, scrollbar, schema, session ... } // /////////////////////////////////////////////// putenv("COLORTERM="); //FIXME: for mc, which cannot detect color terminals int c = 0, l = 0; if ( (strcmp("", sz) != 0) ) { char *ls = strchr( sz.data(), 'x' ); if ( ls != NULL ) { *ls='\0'; ls++; c=atoi(sz); l=atoi(ls); } else { fprintf(stderr, "expected -vt_sz <#columns>x<#lines> ie. 80x40\n" ); } } if (a.isRestored()) { KConfig * sessionconfig = a.getSessionConfig(); sessionconfig->setGroup("options"); sessionconfig->readListEntry("konsolearguments", eargs); wname = sessionconfig->readEntry("class",wname).data(); RESTORE( TEDemo(wname,eargs,login_shell) ) }
void KNNntpClient::doCheckNewGroups() { KNGroupListData *target = static_cast<KNGroupListData *>(job->data()); sendSignal(TSdownloadNewGroups); errorPrefix = i18n("New groups could not be retrieved.\nThe following error occurred:\n"); progressValue = 100; predictedLines = 30; // rule of thumb ;-) QCString cmd; cmd.sprintf("NEWGROUPS %.2d%.2d%.2d 000000", target->fetchSince.year() % 100, target->fetchSince.month(), target->fetchSince.day()); if(!sendCommandWCheck(cmd, 231)) // 231 list of new newsgroups follows return; char *s, *line; QString name; KNGroup::Status status; QSortedList<KNGroupInfo> tmpList; tmpList.setAutoDelete(true); while(getNextLine()) { line = getCurrentLine(); if(line[0] == '.') { if(line[1] == '.') line++; // collapse double period into one else if(line[1] == 0) break; // message complete } s = strchr(line, ' '); if(!s) { #ifndef NDEBUG qDebug("knode: retrieved broken group-line - ignoring"); #endif } else { s[0] = 0; // cut string name = QString::fromUtf8(line); while(s[1] != 0) s++; // the last character determines the moderation status switch(s[0]) { case 'n' : status = KNGroup::readOnly; break; case 'y' : status = KNGroup::postingAllowed; break; case 'm' : status = KNGroup::moderated; break; default : status = KNGroup::unknown; } tmpList.append(new KNGroupInfo(name, QString::null, true, false, status)); } doneLines++; } if(!job->success() || job->canceled()) return; // stopped... if(target->getDescriptions) { errorPrefix = i18n("The group descriptions could not be retrieved.\nThe following error occurred:\n"); progressValue = 100; doneLines = 0; predictedLines = tmpList.count() * 3; sendSignal(TSdownloadDesc); sendSignal(TSprogressUpdate); cmd = "LIST NEWSGROUPS "; QStrList desList; char *s; int rep; for(KNGroupInfo *group = tmpList.first(); group; group = tmpList.next()) { if(!sendCommand(cmd + group->name.utf8(), rep)) return; if(rep != 215) // 215 informations follows break; desList.clear(); if(!getMsg(desList)) return; if(desList.count() > 0) // group has a description { s = desList.first(); while(*s != - '\0' && *s != '\t' && *s != ' ') s++; if(*s == '\0') { #ifndef NDEBUG qDebug("knode: retrieved broken group-description - ignoring"); #endif } else { while(*s == ' ' || *s == '\t') s++; // go on to the description if(target->codecForDescriptions) // some countries use local 8 bit characters in the tag line group->description = target->codecForDescriptions->toUnicode(s); else group->description = QString::fromLocal8Bit(s); } } } } sendSignal(TSloadGrouplist); if(!target->readIn()) { job->setErrorString(i18n("Unable to read the group list file")); return; } target->merge(&tmpList); sendSignal(TSwriteGrouplist); if(!target->writeOut()) { job->setErrorString(i18n("Unable to write the group list file")); return; } }
Kfm::Kfm() { pKfm = this; pHistory = new QStrList; kapp->setTopWidget( this ); HTMLCache::load(); pIconLoader = new KIconLoader(); // We need this in KfmGui::KfmGui(), so moved it here. DF. QStrList* list = pIconLoader->getDirList(); list->clear(); QString tmp = kapp->kde_icondir().copy(); list->append( tmp.data() ); tmp = KApplication::localkdedir(); tmp += "/share/icons"; list->append( tmp.data() ); KConfig *config = kapp->getConfig(); QStrList dirList; config->setGroup("KDE Setup"); config->readListEntry( "IconPath", dirList, ':' ); for (const char *it=dirList.first(); it; it = dirList.next()) { QDir dir( it ); if (dir.exists()) list->append( it ); } if ( KfmGui::rooticons ) { kapp->enableSessionManagement( TRUE ); kapp->setWmCommand( "" ); connect( kapp, SIGNAL( saveYourself() ), this, SLOT( slotSave() ) ); connect( kapp, SIGNAL( shutDown() ), this, SLOT( slotShutDown() ) ); // Global configuration config->setGroup("KFM Misc Defaults"); bAllowURLProps = config->readBoolEntry( "EnablePerURLProps", false ); bTreeViewFollowMode = config->readBoolEntry( "TreeFollowsView", false); config->setGroup( "SM" ); bool flag = config->hasKey( "URLs" ); QStrList urlList; int n = config->readListEntry( "URLs", urlList ); if ( !flag && KfmGui::rooticons == true ) { QString home = "file:"; home.detach(); home += QDir::homeDirPath().data(); KfmGui *m = new KfmGui( 0L, 0L, home.data() ); m->show(); } if ( flag ) { int i; for ( i = 1; i <= n; i++ ) { KfmGui *m = new KfmGui( 0L, 0L, urlList.at( i - 1 ) ); m->readProperties(i); m->show(); } } } // Install HTTP Cookies { KConfig *config = kapp->getConfig(); config->setGroup( "Browser Settings/HTTP" ); bool cookiesEnabled = config->readBoolEntry( "Cookies", true ); if ( cookiesEnabled) { cookiejar = new KCookieJar(); cookiejar->loadConfig( config ); QString cookieFile = kapp->localkdedir().data(); cookieFile += "/share/apps/kfm/cookies"; cookiejar->loadCookies( cookieFile.data() ); } } connect( &timer, SIGNAL( timeout() ), this, SLOT( slotTouch() ) ); // Call every hour timer.start( 3600000 ); }
// scan the relevant parts of the cddba database entry in the the provied structures void CDDB::getData( QString& data, QStrList& titles, QStrList& extlist, QString& categ, QStrList& discidlist, int& revision, QStrList& playlist ){ data = ""; titles.clear(); extlist.clear(); discidlist.clear(); categ = category.copy(); data = respbuffer; data.detach(); int pos1,pos2,pos3,pos4 = 0; int revtmp = data.find("Revision:",0,true); if(revtmp == -1) revision = 1; else{ QString revstr; int revtmp2; revtmp2 = data.find("\n",revtmp,true); if(revtmp2 - revtmp - 9 >=0) revstr = data.mid(revtmp +9,revtmp2 - revtmp -9); revstr.stripWhiteSpace(); bool ok; revision = revstr.toInt(&ok); if(!ok) revision = 1; if (debugflag) fprintf(stderr,"REVISION %d\n",revision); } // lets get all DISCID's in the data. Remeber there can be many DISCID's on // several lines separated by commas on each line // // DISCID= 47842934,4h48393,47839492 // DISCID= 47fd2934,4h48343,47839492,43879074 while((pos3 = data.find("DISCID=",pos4,true))!= -1) { pos1 = pos3; pos2 = data.find("\n",pos1,true); QString discidtemp; QString temp3; if( pos2 - pos1 -7 >= 0){ discidtemp = data.mid(pos1 + 7,pos2- pos1 -7); } else{ if (debugflag) fprintf(stderr,"ANOMALY 1\n"); } if (debugflag) fprintf(stderr,"DISCDID %s\n",discidtemp.data()); pos1 = 0; while((pos2 = discidtemp.find(",",pos1,true)) != -1){ if( pos2 - pos1 >= 0){ temp3 = discidtemp.mid(pos1,pos2-pos1); } else{ if (debugflag) fprintf(stderr,"ANOMALY 2\n"); } temp3 = temp3.stripWhiteSpace(); if(!temp3.isEmpty()) discidlist.append(temp3.data()); pos1 = pos2 + 1; } temp3 = discidtemp.mid(pos1,discidtemp.length()); temp3.stripWhiteSpace(); if(!temp3.isEmpty()) discidlist.append(temp3.data()); pos4 = pos3 + 1; }// end get DISCID's if (debugflag) fprintf(stderr,"FOUND %d DISCID's\n",discidlist.count()); // Get the DTITLE QString value; QString key; key = "DTITLE="; getValue(key,value,data); titles.append(value); int counter = 0; key = key.sprintf("TTITLE%d=",counter); while(getValue(key,value,data)){ titles.append(value); key = key.sprintf("TTITLE%d=",++counter); } key = "EXTD="; getValue(key,value,data); extlist.append(value); counter = 0; key = key.sprintf("EXTT%d=",counter); while(getValue(key,value,data)){ extlist.append(value); key = key.sprintf("EXTT%d=",++counter); } key = "PLAYORDER="; getValue(key,value,data); cddb_playlist_decode(playlist, value); }
bool SGFParser::parseASCIIStream(QTextStream *stream, ASCII_Import *charset) { CHECK_PTR(stream); QStrList asciiLines; asciiLines.setAutoDelete(TRUE); int i=0, first=-1, last=-1, y=1; bool flag=false; QString dummy = QString(QChar(charset->vBorder)).append(charset->vBorder).append(charset->vBorder); // "---" while (!stream->atEnd()) { QString tmp = stream->readLine(); asciiLines.append(tmp.latin1()); if (tmp.find('.') != -1) flag = true; if (tmp.find(dummy) != -1) { if (first == -1 && !flag) first = i; else last = i; } i++; } if (!flag) { GameData gd; QString ascii = asciiLines.getFirst(); // do some fast checks: one line string? qDebug("no standard ASCII file"); int nr = ascii.contains("0") + ascii.contains("b") + ascii.contains("w"); if (nr == 81) { qDebug("found 9x9"); gd.size = 9; gd.komi = 3.5; } else if (nr == 169) { qDebug("found 13x13"); gd.size = 13; gd.komi = 4.5; } else if (nr == 361) { qDebug("found 19x19"); gd.size = 19; gd.komi = 5.5; } else { qDebug(QString("found nr == %1").arg(nr)); return false; } gd.handicap = 0; if (gd.size != boardHandler->board->getBoardSize()) boardHandler->board->initGame(&gd, true); int i = 0; for (int y = 1; y <= gd.size; y++) for (int x = 1; x <= gd.size; x++) { while (ascii[i] != 'b' && ascii[i] != 'w' && ascii[i] != '0') i++; if (ascii[i] == 'b') { boardHandler->addStone(stoneBlack, x, y); } else if (ascii[i] == 'w') { boardHandler->addStone(stoneWhite, x, y); } i++; } asciiLines.clear(); return true; } // qDebug("Y: FIRST = %d, LAST = %d", first, last); if (first == -1 && last != -1) asciiOffsetY = boardHandler->board->getBoardSize() - last; QStrListIterator it(asciiLines); for (; it.current() && y < boardHandler->board->getBoardSize(); ++it) if (!doASCIIParse(it.current(), y, charset)) return false; asciiLines.clear(); return true; }