void KNNntpClient::doPostArticle() { KNLocalArticle *art = static_cast<KNLocalArticle *>(job->data()); sendSignal(TSsendArticle); if(art->messageID(false) != 0) { int rep; if(!sendCommand(QCString("STAT ") + art->messageID(false)->as7BitString(false), rep)) return; if(rep == 223) // 223 n <a> article retrieved - request text separately { #ifndef NDEBUG qDebug("knode: STAT successful, we have probably already sent this article."); #endif return; // the article is already on the server, lets put it silently into the send folder } } if(!sendCommandWCheck("POST", 340)) // 340 send article to be posted. End with <CR-LF>.<CR-LF> return; if(art->messageID(false) == 0) // article has no message ID => search for a ID in the response { QCString s = getCurrentLine(); int start = s.findRev(QRegExp("<[^\\s]*@[^\\s]*>")); if(start != -1) // post response includes a recommended id { int end = s.find('>', start); art->messageID()->from7BitString(s.mid(start, end - start + 1)); art->assemble(); #ifndef NDEBUG qDebug("knode: using the message-id recommended by the server: %s", s.mid(start, end - start + 1).data()); #endif } } if(!sendMsg(art->encodedContent(true))) return; if(!checkNextResponse(240)) // 240 article posted ok return; }
void UmlRelation::uml2java(bool) { switch (relationKind()) { case aGeneralisation: case aRealization: set_JavaDecl("${type}"); break; case aDependency: break; default: { QCString st = JavaSettings::classStereotype(parent()->stereotype()); set_JavaDecl(((st == "enum") || (st == "ignored")) ? QCString("") : JavaSettings::relationDecl(multiplicity())); } } }
KParts::Part* KonferencePartFactory::createPartObject( QWidget *parentWidget, const char *widgetName, QObject *parent, const char *name, const char *classname, const QStringList &args ) { // Create an instance of our Part KonferencePart* obj = new KonferencePart( parentWidget, widgetName, parent, name ); // See if we are to be read-write or not if (QCString(classname) == "KParts::ReadOnlyPart") { //this is only here, so that the compiler not complains about unused variables } //this as well QString tmp = args.first(); //obj->setReadWrite(false); return obj; }
void ProcAttachPS::slotTextReceived(KProcess*, char* buffer, int buflen) { const char* end = buffer+buflen; while (buffer < end) { // check new line if (*buffer == '\n') { // push a tokens onto the line if (!m_token.isEmpty()) { m_line.push_back(QString::fromLatin1(m_token)); m_token = ""; } // and insert the line in the list pushLine(); m_line.clear(); ++buffer; } // blanks: the last column gets the rest of the line, including blanks else if ((m_pidCol < 0 || int(m_line.size()) < processList->columns()-1) && isspace(*buffer)) { // push a token onto the line if (!m_token.isEmpty()) { m_line.push_back(QString::fromLatin1(m_token)); m_token = ""; } do { ++buffer; } while (buffer < end && isspace(*buffer)); } // tokens else { const char* start = buffer; do { ++buffer; } while (buffer < end && !isspace(*buffer)); // append to the current token m_token += QCString(start, buffer-start+1); // must count the '\0' } } }
QDragObject *KivioIconView::dragObject() { if( !currentItem() || !isReadWrite) return 0; QPoint orig = viewportToContents( viewport()->mapFromGlobal( QCursor::pos() ) ); KivioSpawnerDrag *drag = new KivioSpawnerDrag( this, viewport() ); const char*null_pix[]={ "1 1 1 1", "# c None", "#"}; drag->setPixmap(null_pix); KivioIconViewItem *item = (KivioIconViewItem *)currentItem(); QIconDragItem id; QString full; full = item->spawner()->set()->dir() + "/" + item->spawner()->info()->title(); id.setData( QCString(full.ascii())); drag->append( id, QRect( item->pixmapRect(FALSE).x() - orig.x(), item->pixmapRect(FALSE).y() - orig.y(), item->pixmapRect().width(), item->pixmapRect().height() ), QRect( item->textRect(FALSE).x() - orig.x(), item->textRect(FALSE).y() - orig.y(), item->textRect().width(), item->textRect().height() ), *(item->spawner()) ); // Set the current dragged KivioStencilSpawner for use // when the drop occurs. I don't actually encode the // data because it's a pain in the ass and I don't understand // how to do it. So I store a pointer here and clear // it on the drop. m_pCurDrag = item->spawner(); return drag; }
void QDesignerToolBar::buttonMouseMoveEvent( QMouseEvent *e, QObject *o ) { if ( widgetInserting || ( e->state() & LeftButton ) == 0 ) return; if ( QABS( QPoint( dragStartPos - e->pos() ).manhattanLength() ) < QApplication::startDragDistance() ) return; QMap<QWidget*, QAction*>::Iterator it = actionMap.find( (QWidget*)o ); if ( it == actionMap.end() ) return; QAction *a = *it; if ( !a ) return; int index = actionList.find( a ); RemoveActionFromToolBarCommand *cmd = new RemoveActionFromToolBarCommand( tr( "Delete Action '%1' from Toolbar '%2'" ). arg( a->name() ).arg( caption() ), formWindow, a, this, index ); formWindow->commandHistory()->addCommand( cmd ); cmd->execute(); QApplication::sendPostedEvents(); adjustSize(); QString type = ::qt_cast<QActionGroup*>(a) ? QString( "application/x-designer-actiongroup" ) : ::qt_cast<QSeparatorAction*>(a) ? QString( "application/x-designer-separator" ) : QString( "application/x-designer-actions" ); QStoredDrag *drag = new QStoredDrag( type, this ); QString s = QString::number( (long)a ); // #### huha, that is evil drag->setEncodedData( QCString( s.latin1() ) ); drag->setPixmap( a->iconSet().pixmap() ); if ( ::qt_cast<QDesignerAction*>(a) ) { if ( formWindow->widgets()->find( ( (QDesignerAction*)a )->widget() ) ) formWindow->selectWidget( ( (QDesignerAction*)a )->widget(), FALSE ); } if ( !drag->drag() ) { AddActionToToolBarCommand *cmd = new AddActionToToolBarCommand( tr( "Add Action '%1' to Toolbar '%2'" ). arg( a->name() ).arg( caption() ), formWindow, a, this, index ); formWindow->commandHistory()->addCommand( cmd ); cmd->execute(); } lastIndicatorPos = QPoint( -1, -1 ); indicator->hide(); }
void OutputList::parseDoc(const char *fileName,int startLine, Definition *ctx,MemberDef * md, const QCString &docStr,bool indexWords, bool isExample,const char *exampleName, bool singleLine,bool linkFromIndex) { int count=0; if (docStr.isEmpty()) return; OutputGenerator *og=outputs->first(); while (og) { if (og->isEnabled()) count++; og=outputs->next(); } if (count==0) return; // no output formats enabled. DocNode *root=0; if (docStr.at(docStr.length()-1)=='\n') { root = validatingParseDoc(fileName,startLine, ctx,md,docStr,indexWords,isExample,exampleName, singleLine,linkFromIndex); } else { root = validatingParseDoc(fileName,startLine, ctx,md,docStr+"\n",indexWords,isExample,exampleName, singleLine,linkFromIndex); } og=outputs->first(); while (og) { //printf("og->printDoc(extension=%s)\n", // ctx?ctx->getDefFileExtension().data():"<null>"); if (og->isEnabled()) og->printDoc(root,ctx?ctx->getDefFileExtension():QCString("")); og=outputs->next(); } delete root; }
void ServiceListener::slotDBusSignal( const QDBusMessage& message ) { odebug << "ConnMan: " << message.member() << oendl; if( message.member() == "PropertyChanged" ) { QString prop = message[0].toString(); if( prop == "State" ) { QString oldState = m_state; QString newState = message[1].toVariant().value.toString(); if( oldState != newState ) { emit serviceStateChanged( QDBusObjectPath( QCString( m_proxy->path() )), oldState, newState ); m_state = newState; sendSignalStrength(); } } else if( prop == "Strength" ) { m_strength = message[1].toVariant().value.toByte(); sendSignalStrength(); } } }
void MetaTranslator::stripEmptyContexts() { TMM newmm; TMM::Iterator m = mm.begin(); while ( m != mm.end() ) { if ( QCString(m.key().sourceText()) == ContextComment ) { TMM::Iterator n = m; ++n; // the context comment is followed by other messages if ( n != newmm.end() && qstrcmp(m.key().context(), n.key().context()) == 0 ) newmm.insert( m.key(), *m ); } else { newmm.insert( m.key(), *m ); } ++m; } mm = newmm; }
void KGPGFile::close(void) { // qDebug("KGPGFile::close()"); if(!isOpen()) { // qDebug("File not open"); return; } // finish the KProcess and clean up things if(m_process) { if(isWritable()) { // qDebug("Finish writing"); if(m_process->isRunning()) { m_process->closeStdin(); // now wait for GPG to finish m_needExitLoop = true; qApp->enter_loop(); } else m_process->kill(); } else if(isReadable()) { // qDebug("Finish reading"); if(m_process->isRunning()) { m_process->closeStdout(); // now wait for GPG to finish m_needExitLoop = true; qApp->enter_loop(); } else m_process->kill(); } } m_ungetchBuffer = QCString(); setState(0); m_recipient.clear(); // qDebug("File closed"); }
void Nntp::parseArticle() { if ( !commandSocket->canReadLine() ) return; // read an article one line after the other while ( commandSocket->canReadLine() ) { QString s = commandSocket->readLine(); // if the line starts with a dot, we finished reading something if ( s[ 0 ] == '.' ) { readArticle = FALSE; operationInProgress()->setState( StDone ); emit finished( operationInProgress() ); return; } if ( s.right( 1 ) == "\n" ) s.remove( s.length() - 1, 1 ); // emit the new data of the article which we read emit data( QCString( s.ascii() ), operationInProgress() ); } }
/****************************************************************************** * Register this application with the alarm daemon, and tell it to load the * calendar. * Set 'reregister' true in order to notify the daemon of a change in the * 'disable alarms if stopped' setting. */ bool Daemon::registerWith(bool reregister) { if (mRegisterTimer) return true; switch (mStatus) { case STOPPED: case RUNNING: return false; case REGISTERED: if (!reregister) return true; break; case READY: break; } bool disabledIfStopped = theApp()->alarmsDisabledIfStopped(); kdDebug(5950) << (reregister ? "Daemon::reregisterWith(): " : "Daemon::registerWith(): ") << (disabledIfStopped ? "NO_START" : "COMMAND_LINE") << endl; QCString appname = kapp->aboutData()->appName(); AlarmDaemonIface_stub s(DAEMON_APP_NAME, DAEMON_DCOP_OBJECT); if (reregister) s.registerChange(appname, !disabledIfStopped); else s.registerApp(appname, kapp->aboutData()->programName(), QCString(NOTIFY_DCOP_OBJECT), AlarmCalendar::activeCalendar()->urlString(), !disabledIfStopped); if (!s.ok()) { kdError(5950) << "Daemon::registerWith(" << reregister << "): DCOP error" << endl; registrationResult(reregister, KAlarmd::FAILURE); return false; } mRegisterTimer = new QTimer(mInstance); connect(mRegisterTimer, SIGNAL(timeout()), mInstance, SLOT(registerTimerExpired())); mRegisterTimer->start(REGISTER_TIMEOUT * 1000); // wait for the reply return true; }
int main(int argc, char ** argv) { int port_index; if (argc == 2) port_index = 1; else if (argc == 3) { set_verbose(); port_index = 2; } else return 0; if (UmlCom::connect(QCString(argv[port_index]).toUInt())) { try { UmlCom::trace("<b>IDL generator</b> release 2.15<br>"); UmlCom::targetItem()->generate(); QCString s; s.sprintf("<hr><font face=helvetica>Generation done : %d warnings, %d errors</font><br>", n_warnings(), n_errors()); UmlCom::trace(s); UmlCom::message(""); UmlCom::bye(n_errors()); } catch (...) { } } UmlCom::close(); return 0; }
void SearchIndex::addWord(const char *word,bool hiPriority,bool recurse) { static QRegExp nextPart("[_a-z:][A-Z]"); if (word==0 || word[0]=='\0') return; QCString wStr = QCString(word).lower(); //printf("SearchIndex::addWord(%s,%d) wStr=%s\n",word,hiPriority,wStr.data()); IndexWord *w = m_words[wStr]; if (w==0) { int idx=charsToIndex(wStr); //fprintf(stderr,"addWord(%s) at index %d\n",word,idx); if (idx<0) return; w = new IndexWord(wStr); m_index[idx]->append(w); m_words.insert(wStr,w); } w->addUrlIndex(m_urlIndex,hiPriority); int i; bool found=FALSE; if (!recurse) // the first time we check if we can strip the prefix { i=getPrefixIndex(word); if (i>0) { addWord(word+i,hiPriority,TRUE); found=TRUE; } } if (!found) // no prefix stripped { if ((i=nextPart.match(word))>=1) { addWord(word+i+1,hiPriority,TRUE); } } }
QCString Definition::briefDescriptionAsTooltip() const { if (m_impl->brief) { if (m_impl->brief->tooltip.isEmpty() && !m_impl->brief->doc.isEmpty()) { static bool reentering=FALSE; if (!reentering) { /* MemberDef *md = definitionType()==TypeMember ? (MemberDef*)this : 0; const Definition *scope = definitionType()==TypeMember ? getOuterScope() : this; reentering=TRUE; // prevent requests for tooltips while parsing a tooltip m_impl->brief->tooltip = parseCommentAsText( scope,md, m_impl->brief->doc, m_impl->brief->file, m_impl->brief->line); reentering=FALSE; */ } } return m_impl->brief->tooltip; } return QCString(""); }
static void read_bodies(const char * path, QIntDict<char> & bodies) { char * s = read_file(path); if (s != 0) { char * p1 = s; char * p2; while ((p2 = strstr(p1, BodyPrefix)) != 0) { p2 += BodyPrefixLength; char * body; long id = strtol(p2, &body, 16); if (body != (p2 + 8)) { UmlCom::trace(QCString("<font color =\"red\"> Error in ") + path + " : invalid preserve body identifier</font><br>"); UmlCom::bye(n_errors() + 1); UmlCom::fatal_error("read_bodies 1"); } if (bodies.find(id) != 0) { UmlCom::trace(QCString("<font color =\"red\"> Error in ") + path + " : preserve body identifier used twice</font><br>"); UmlCom::bye(n_errors() + 1); UmlCom::fatal_error("read_bodies 2"); } if (*body == '\r') body += 1; if (*body == '\n') body += 1; else { UmlCom::trace(QCString("<font color =\"red\"> Error in ") + path + " : invalid preserve body block, end of line expected</font><br>"); UmlCom::bye(n_errors() + 1); UmlCom::fatal_error("read_bodies 3"); } if (((p1 = strstr(body, BodyPostfix)) == 0) || (strncmp(p1 + BodyPostfixLength, p2, 8) != 0)) { UmlCom::trace(QCString("<font color =\"red\"> Error in ") + path + " : invalid preserve body block, wrong balanced</font><br>"); UmlCom::bye(n_errors() + 1); UmlCom::fatal_error("read_bodies 4"); } p2 = p1; while ((p2 != body) && (p2[-1] != '\n')) p2 -= 1; *p2 = 0; int len = p2 - body + 1; char * b = new char[len]; memcpy(b, body, len); bodies.insert(id, b); p1 += BodyPostfixLength + 8; } delete [] s; } }
bool KStandardDirs::addCustomized(KConfig *config) { if (addedCustoms && !d->checkRestrictions) // there are already customized entries return false; // we just quit and hope they are the right ones // save the numbers of config directories. If this changes, // we will return true to give KConfig a chance to reparse uint configdirs = resourceDirs("config").count(); // Remember original group QString oldGroup = config->group(); if (!addedCustoms) { // We only add custom entries once addedCustoms = true; // reading the prefixes in QString group = QString::fromLatin1("Directories"); config->setGroup(group); QString kioskAdmin = config->readEntry("kioskAdmin"); if (!kioskAdmin.isEmpty() && !kde_kiosk_admin) { int i = kioskAdmin.find(':'); QString user = kioskAdmin.left(i); QString host = kioskAdmin.mid(i+1); KUser thisUser; char hostname[ 256 ]; hostname[ 0 ] = '\0'; if (!gethostname( hostname, 255 )) hostname[sizeof(hostname)-1] = '\0'; if ((user == thisUser.loginName()) && (host.isEmpty() || (host == hostname))) { kde_kiosk_admin = true; } } bool readProfiles = true; if (kde_kiosk_admin && !QCString(getenv("KDE_KIOSK_NO_PROFILES")).isEmpty()) readProfiles = false; QString userMapFile = config->readEntry("userProfileMapFile"); QString profileDirsPrefix = config->readEntry("profileDirsPrefix"); if (!profileDirsPrefix.isEmpty() && !profileDirsPrefix.endsWith("/")) profileDirsPrefix.append('/'); QStringList profiles; if (readProfiles) profiles = lookupProfiles(userMapFile); QString profile; bool priority = false; while(true) { config->setGroup(group); QStringList list = config->readListEntry("prefixes"); for (QStringList::ConstIterator it = list.begin(); it != list.end(); ++it) { addPrefix(*it, priority); addXdgConfigPrefix(*it+"/etc/xdg", priority); addXdgDataPrefix(*it+"/share", priority); } // If there are no prefixes defined, check if there is a directory // for this profile under <profileDirsPrefix> if (list.isEmpty() && !profile.isEmpty() && !profileDirsPrefix.isEmpty()) { QString dir = profileDirsPrefix + profile; addPrefix(dir, priority); addXdgConfigPrefix(dir+"/etc/xdg", priority); addXdgDataPrefix(dir+"/share", priority); } // iterating over all entries in the group Directories // to find entries that start with dir_$type QMap<QString, QString> entries = config->entryMap(group); for (QMap<QString, QString>::ConstIterator it2 = entries.begin(); it2 != entries.end(); it2++) { QString key = it2.key(); if (key.startsWith("dir_")) { // generate directory list, there may be more than 1. QStringList dirs = QStringList::split(',', *it2); QStringList::Iterator sIt(dirs.begin()); QString resType = key.mid(4, key.length()); for (; sIt != dirs.end(); ++sIt) { addResourceDir(resType.latin1(), *sIt, priority); } } } if (profiles.isEmpty()) break; profile = profiles.back(); group = QString::fromLatin1("Directories-%1").arg(profile); profiles.pop_back(); priority = true; } } // Process KIOSK restrictions. if (!kde_kiosk_admin || QCString(getenv("KDE_KIOSK_NO_RESTRICTIONS")).isEmpty()) { config->setGroup("KDE Resource Restrictions"); QMap<QString, QString> entries = config->entryMap("KDE Resource Restrictions"); for (QMap<QString, QString>::ConstIterator it2 = entries.begin(); it2 != entries.end(); it2++) { QString key = it2.key(); if (!config->readBoolEntry(key, true)) { d->restrictionsActive = true; d->restrictions.insert(key.latin1(), &d->restrictionsActive); // Anything will do dircache.remove(key.latin1()); } } } config->setGroup(oldGroup); // check if the number of config dirs changed bool configDirsChanged = (resourceDirs("config").count() != configdirs); // If the config dirs changed, we check kiosk restrictions again. d->checkRestrictions = configDirsChanged; // return true if the number of config dirs changed: reparse config file return configDirsChanged; }
servercontroller::servercontroller( QWidget*, const char* name ) : KMainWindow( 0, name ) { we_are_exiting = false; m_notificationCount = 0; m_ncm = new nickColourMaker(); MenuBar = menuBar(); KWin::setIcons( winId(), kapp->icon(), kapp->miniIcon() ); s_self = this; switch (ksopts->displayMode) { case KSOptions::SDI: displayMgr = new DisplayMgrSDI(); break; case KSOptions::MDI: displayMgr = new DisplayMgrMDI(); break; } sci = new scInside(this, QCString(name) + "_mainview"); setCentralWidget(sci); sci->setFrameStyle(QFrame::Box | QFrame::Raised); ConnectionTree = sci->ConnectionTree; connect(ConnectionTree, SIGNAL(clicked( QListViewItem * )), this, SLOT(WindowSelected(QListViewItem *))); setFrameBorderWidth(5); QPopupMenu *file = new QPopupMenu(this, QCString(name) + "_menu_file"); KStdAction::quit(this, SLOT(endksirc()), actionCollection())->plug(file); #ifndef NDEBUG file->insertItem(i18n("Dump Object Tree"), this, SLOT(dump_obj())); file->insertItem(i18n("Server Debug Window"), this, SLOT(server_debug())); #endif MenuBar->insertItem(i18n("&File"), file); connections = new QPopupMenu(this, QCString(name) + "_menu_connections"); server_id = connections->insertItem(i18n("&New Server..."), this, SLOT(new_connection()), Key_F2 ); join_id = connections->insertItem(i18n("&Join Channel..."), this, SLOT(new_channel()), Key_F3 ); connections->insertSeparator(); connections->insertItem(i18n("&Do Autoconnect..."), this, SLOT(start_autoconnect_check())); connections->setItemEnabled(join_id, FALSE); MenuBar->insertItem(i18n("&Connections"), connections); options = new QPopupMenu(this, QCString(name) + "_menu_options"); options->setCheckable(TRUE); options->insertItem(SmallIcon( "filter" ), i18n("&Filter Rule Editor..."), this, SLOT(filter_rule_editor())); options->insertSeparator(); KStdAction::configureNotifications(this, SLOT(notification_prefs()), actionCollection())->plug(options); KStdAction::preferences(this, SLOT(general_prefs()), actionCollection())->plug(options); MenuBar->insertItem(i18n("&Settings"), options); KHelpMenu *help = new KHelpMenu( this, kapp->aboutData() ); MenuBar->insertItem( KStdGuiItem::help().text(), help->menu() ); m_kga = new KGlobalAccel(this, "globalAccess"); m_kga->insert("New Server", i18n("New Server"), i18n("This action allows you to open a new server more easily " "when in docked mode, since you don't need to click on the " "dock icon."), ALT+CTRL+Key_C, KKey::QtWIN+CTRL+Key_C, this, SLOT(new_connection())); open_toplevels = 0; pic_server = UserIcon("server"); pic_gf = UserIcon("ksirc_a"); pic_run = UserIcon("mini-run"); pic_ppl = UserIcon("channels"); pic_icon = UserIcon("ksirc_b"); setCaption( i18n("Server Control") ); KWin::setIcons(winId(), pic_icon, pic_server); resize( 450,200 ); dockWidget = new dockServerController(this, 0x0, "servercontroller_dock"); KWin::setSystemTrayWindowFor( dockWidget->winId(), winId() ); m_kga->readSettings(); m_kga->updateConnections(); checkDocking(); }
int main(int argc, char **argv) { // Ensure that user configuration doesn't change the results of those tests // KDEHOME needs to be writable though, for a ksycoca database setenv("KDEHOME", QFile::encodeName(QDir::homeDirPath() + "/.kde-kurifiltertest"), true); setenv("KDE_FORK_SLAVES", "yes", true); // simpler, for the final cleanup KAboutData aboutData(appName, programName, version, description); KCmdLineArgs::init(argc, argv, &aboutData); KCmdLineArgs::addCmdLineOptions(options); KApplication app; app.disableAutoDcopRegistration(); // Allow testing of the search engine using both delimiters... char delimiter = KCmdLineArgs::parsedArgs()->isSet("s") ? ' ' : ':'; // Many tests check the "default search engine" feature. // There is no default search engine by default (since it was annoying when making typos), // so the user has to set it up, which we do here. { KSimpleConfig cfg("kuriikwsfilterrc"); cfg.setGroup("General"); cfg.writeEntry("DefaultSearchEngine", "google"); cfg.writeEntry("Verbose", true); cfg.writeEntry("KeywordDelimiter", delimiter); cfg.sync(); } // Enable verbosity for debugging { KSimpleConfig cfg("kshorturifilterrc"); cfg.writeEntry("Verbose", true); cfg.sync(); } QStringList minicliFilters; minicliFilters << "kshorturifilter" << "kurisearchfilter" << "localdomainurifilter"; // URI that should require no filtering filter("http://www.kde.org", "http://www.kde.org", KURIFilterData::NET_PROTOCOL); filter("http://www.kde.org/developer//index.html", "http://www.kde.org/developer//index.html", KURIFilterData::NET_PROTOCOL); // URL with reference filter("http://www.kde.org/index.html#q8", "http://www.kde.org/index.html#q8", KURIFilterData::NET_PROTOCOL); // local file with reference filter("file:/etc/passwd#q8", "file:///etc/passwd#q8", KURIFilterData::LOCAL_FILE); filter("file:///etc/passwd#q8", "file:///etc/passwd#q8", KURIFilterData::LOCAL_FILE); filter("/etc/passwd#q8", "file:///etc/passwd#q8", KURIFilterData::LOCAL_FILE); // local file with query (can be used by javascript) filter("file:/etc/passwd?foo=bar", "file:///etc/passwd?foo=bar", KURIFilterData::LOCAL_FILE); testLocalFile("/tmp/kurifiltertest?foo"); // local file with ? in the name (#58990) testLocalFile("/tmp/kurlfiltertest#foo"); // local file with '#' in the name testLocalFile("/tmp/kurlfiltertest#foo?bar"); // local file with both testLocalFile("/tmp/kurlfiltertest?foo#bar"); // local file with both, the other way round // hostnames are lowercased by KURL filter("http://www.myDomain.commyPort/ViewObjectRes//Default:name=hello", "http://www.mydomain.commyport/ViewObjectRes//Default:name=hello", KURIFilterData::NET_PROTOCOL); filter("ftp://ftp.kde.org", "ftp://ftp.kde.org", KURIFilterData::NET_PROTOCOL); filter("ftp://[email protected]:500", "ftp://[email protected]:500", KURIFilterData::NET_PROTOCOL); // ShortURI/LocalDomain filter tests. NOTE: any of these tests can fail // if you have specified your own patterns in kshorturifilterrc. For // examples, see $KDEDIR/share/config/kshorturifilterrc . filter("linuxtoday.com", "http://linuxtoday.com", KURIFilterData::NET_PROTOCOL); filter("LINUXTODAY.COM", "http://linuxtoday.com", KURIFilterData::NET_PROTOCOL); filter("kde.org", "http://kde.org", KURIFilterData::NET_PROTOCOL); filter("ftp.kde.org", "ftp://ftp.kde.org", KURIFilterData::NET_PROTOCOL); filter("ftp.kde.org:21", "ftp://ftp.kde.org:21", KURIFilterData::NET_PROTOCOL); filter("cr.yp.to", "http://cr.yp.to", KURIFilterData::NET_PROTOCOL); filter("[email protected]:3128", "http://[email protected]:3128", KURIFilterData::NET_PROTOCOL); filter("127.0.0.1", "http://127.0.0.1", KURIFilterData::NET_PROTOCOL); filter("127.0.0.1:3128", "http://127.0.0.1:3128", KURIFilterData::NET_PROTOCOL); filter("*****@*****.**", "mailto:[email protected]", KURIFilterData::NET_PROTOCOL); filter("*****@*****.**", "mailto:[email protected]", KURIFilterData::NET_PROTOCOL); filter("www.123.foo", "http://www.123.foo", KURIFilterData::NET_PROTOCOL); filter("[email protected]:3128", "http://[email protected]:3128", KURIFilterData::NET_PROTOCOL); // Exotic IPv4 address formats... filter("127.1", "http://127.1", KURIFilterData::NET_PROTOCOL); filter("127.0.1", "http://127.0.1", KURIFilterData::NET_PROTOCOL); // Local domain filter - If you uncomment these test, make sure you // you adjust it based on the localhost entry in your /etc/hosts file. // filter( "localhost:3128", "http://localhost.localdomain:3128", KURIFilterData::NET_PROTOCOL ); // filter( "localhost", "http://localhost.localdomain", KURIFilterData::NET_PROTOCOL ); // filter( "localhost/~blah", "http://localhost.localdomain/~blah", KURIFilterData::NET_PROTOCOL ); filter("/", "/", KURIFilterData::LOCAL_DIR); filter("/", "/", KURIFilterData::LOCAL_DIR, "kshorturifilter"); filter("~/.bashrc", QDir::homeDirPath().local8Bit() + "/.bashrc", KURIFilterData::LOCAL_FILE, "kshorturifilter"); filter("~", QDir::homeDirPath().local8Bit(), KURIFilterData::LOCAL_DIR, "kshorturifilter", "/tmp"); filter("~foobar", 0, KURIFilterData::ERROR, "kshorturifilter"); filter("*****@*****.**", "mailto:[email protected]", KURIFilterData::NET_PROTOCOL); // new in KDE-3.2 // Windows style SMB (UNC) URL. Should be converted into the valid smb format... filter("\\\\mainserver\\share\\file", "smb://mainserver/share/file", KURIFilterData::NET_PROTOCOL); // Should not be filtered at all. All valid protocols of this form will be ignored. filter("ftp:", "ftp:", KURIFilterData::UNKNOWN); filter("http:", "http:", KURIFilterData::UNKNOWN); /* Automatic searching tests. NOTE: If the Default search engine is set to 'None', this stuff will fail as the status returned will then be KURIFilterData::UNKNOWN. */ filter("gg:", 0, KURIFilterData::NET_PROTOCOL); filter("KDE", 0, KURIFilterData::NET_PROTOCOL); filter("FTP", 0, KURIFilterData::NET_PROTOCOL); // If your default search engine is set to 'Google', you can uncomment the test below. filter("gg:", "http://www.google.com/search?q=gg%3A&ie=UTF-8&oe=UTF-8", KURIFilterData::NET_PROTOCOL); filter("KDE", "http://www.google.com/search?q=KDE&ie=UTF-8&oe=UTF-8", KURIFilterData::NET_PROTOCOL); filter("FTP", "http://www.google.com/search?q=FTP&ie=UTF-8&oe=UTF-8", KURIFilterData::NET_PROTOCOL); // Typing 'cp' or any other valid unix command in konq's location bar should result in // a search using the default search engine // 'ls' is a bit of a special case though, due to the toplevel domain called 'ls' filter("cp", "http://www.google.com/search?q=cp&ie=UTF-8&oe=UTF-8", KURIFilterData::NET_PROTOCOL, QStringList(), 0, false /* don't check for executables, see konq_misc.cc */); // Executable tests - No IKWS in minicli filter("cp", "cp", KURIFilterData::EXECUTABLE, minicliFilters); filter("kfmclient", "kfmclient", KURIFilterData::EXECUTABLE, minicliFilters); filter("xwininfo", "xwininfo", KURIFilterData::EXECUTABLE, minicliFilters); filter("KDE", "KDE", NO_FILTERING, minicliFilters); filter("I/dont/exist", "I/dont/exist", NO_FILTERING, minicliFilters); filter("/I/dont/exist", 0, KURIFilterData::ERROR, minicliFilters); filter("/I/dont/exist#a", 0, KURIFilterData::ERROR, minicliFilters); filter("kfmclient --help", "kfmclient --help", KURIFilterData::EXECUTABLE, minicliFilters); // the args are in argsAndOptions() filter("/usr/bin/gs", "/usr/bin/gs", KURIFilterData::EXECUTABLE, minicliFilters); filter("/usr/bin/gs -q -option arg1", "/usr/bin/gs -q -option arg1", KURIFilterData::EXECUTABLE, minicliFilters); // the args are in argsAndOptions() // ENVIRONMENT variable setenv("SOMEVAR", "/somevar", 0); setenv("ETC", "/etc", 0); QCString qtdir = getenv("QTDIR"); QCString home = getenv("HOME"); QCString kdehome = getenv("KDEHOME"); filter("$SOMEVAR/kdelibs/kio", 0, KURIFilterData::ERROR); // note: this dir doesn't exist... filter("$ETC/passwd", "/etc/passwd", KURIFilterData::LOCAL_FILE); filter("$QTDIR/doc/html/functions.html#s", QCString("file://") + qtdir + "/doc/html/functions.html#s", KURIFilterData::LOCAL_FILE); filter("http://www.kde.org/$USER", "http://www.kde.org/$USER", KURIFilterData::NET_PROTOCOL); // no expansion // Assume the default (~/.kde) if if(kdehome.isEmpty()) { kdehome += "$HOME/.kde"; setenv("KDEHOME", kdehome.data(), 0); } filter("$KDEHOME/share", kdehome + "/share", KURIFilterData::LOCAL_DIR); KStandardDirs::makeDir(kdehome + "/a+plus"); filter("$KDEHOME/a+plus", kdehome + "/a+plus", KURIFilterData::LOCAL_DIR); // BR 27788 KStandardDirs::makeDir(kdehome + "/share/Dir With Space"); filter("$KDEHOME/share/Dir With Space", kdehome + "/share/Dir With Space", KURIFilterData::LOCAL_DIR); // support for name filters (BR 93825) filter("$KDEHOME/*.txt", kdehome + "/*.txt", KURIFilterData::LOCAL_DIR); filter("$KDEHOME/[a-b]*.txt", kdehome + "/[a-b]*.txt", KURIFilterData::LOCAL_DIR); filter("$KDEHOME/a?c.txt", kdehome + "/a?c.txt", KURIFilterData::LOCAL_DIR); filter("$KDEHOME/?c.txt", kdehome + "/?c.txt", KURIFilterData::LOCAL_DIR); // but let's check that a directory with * in the name still works KStandardDirs::makeDir(kdehome + "/share/Dir*With*Stars"); filter("$KDEHOME/share/Dir*With*Stars", kdehome + "/share/Dir*With*Stars", KURIFilterData::LOCAL_DIR); KStandardDirs::makeDir(kdehome + "/share/Dir?QuestionMark"); filter("$KDEHOME/share/Dir?QuestionMark", kdehome + "/share/Dir?QuestionMark", KURIFilterData::LOCAL_DIR); KStandardDirs::makeDir(kdehome + "/share/Dir[Bracket"); filter("$KDEHOME/share/Dir[Bracket", kdehome + "/share/Dir[Bracket", KURIFilterData::LOCAL_DIR); filter("$HOME/$KDEDIR/kdebase/kcontrol/ebrowsing", 0, KURIFilterData::ERROR); filter("$1/$2/$3", "http://www.google.com/search?q=$1/$2/$3&ie=UTF-8&oe=UTF-8", KURIFilterData::NET_PROTOCOL); // can be used as bogus or valid test. Currently triggers default search, i.e. google filter("$$$$", "http://www.google.com/search?q=$$$$&ie=UTF-8&oe=UTF-8", KURIFilterData::NET_PROTOCOL); // worst case scenarios. // Replaced the match testing with a 0 since // the shortURI filter will return the string // itself if the requested environment variable // is not already set. filter("$QTDIR", 0, KURIFilterData::LOCAL_DIR, "kshorturifilter"); // use specific filter. filter("$HOME", home, KURIFilterData::LOCAL_DIR, "kshorturifilter"); // use specific filter. QCString sc; filter(sc.sprintf("gg%cfoo bar", delimiter), "http://www.google.com/search?q=foo+bar&ie=UTF-8&oe=UTF-8", KURIFilterData::NET_PROTOCOL); filter(sc.sprintf("bug%c55798", delimiter), "http://bugs.kde.org/show_bug.cgi?id=55798", KURIFilterData::NET_PROTOCOL); filter(sc.sprintf("gg%cC++", delimiter), "http://www.google.com/search?q=C%2B%2B&ie=UTF-8&oe=UTF-8", KURIFilterData::NET_PROTOCOL); filter(sc.sprintf("ya%cfoo bar was here", delimiter), 0, -1); // this triggers default search, i.e. google filter(sc.sprintf("gg%cwww.kde.org", delimiter), "http://www.google.com/search?q=www.kde.org&ie=UTF-8&oe=UTF-8", KURIFilterData::NET_PROTOCOL); filter(sc.sprintf("av%c+rock +sample", delimiter), "http://www.altavista.com/cgi-bin/query?pg=q&kl=XX&stype=stext&q=%2Brock+%2Bsample", KURIFilterData::NET_PROTOCOL); filter(sc.sprintf("gg%cé", delimiter) /*eaccent in utf8*/, "http://www.google.com/search?q=%C3%A9&ie=UTF-8&oe=UTF-8", KURIFilterData::NET_PROTOCOL); filter(sc.sprintf("gg%cпрйвет", delimiter) /* greetings in russian utf-8*/, "http://www.google.com/search?q=%D0%BF%D1%80%D0%B9%D0%B2%D0%B5%D1%82&ie=UTF-8&oe=UTF-8", KURIFilterData::NET_PROTOCOL); // Absolute Path tests for kshorturifilter filter("./", kdehome + "/share", KURIFilterData::LOCAL_DIR, "kshorturifilter", kdehome + "/share/"); // cleanDirPath removes the trailing slash filter("../", kdehome, KURIFilterData::LOCAL_DIR, "kshorturifilter", kdehome + "/share"); filter("config", kdehome + "/share/config", KURIFilterData::LOCAL_DIR, "kshorturifilter", kdehome + "/share"); // Clean up KIO::NetAccess::del(kdehome, 0); kdDebug() << "All tests done. Go home..." << endl; return 0; }
static QCString orginalRecipient( const QCString & recipient ) { if ( recipient.isEmpty() ) return QCString(); else return "Original-Recipient: " + recipient + "\n"; }
void SearchIndex::setCurrentDoc(Definition *ctx,const char *anchor,bool isSourceFile) { if (ctx==0) return; assert(!isSourceFile || ctx->definitionType()==Definition::TypeFile); //printf("SearchIndex::setCurrentDoc(%s,%s,%s)\n",name,baseName,anchor); QCString url=isSourceFile ? ((FileDef*)ctx)->getSourceFileBase() : ctx->getOutputFileBase(); url+=Config_getString("HTML_FILE_EXTENSION"); if (anchor) url+=QCString("#")+anchor; QCString name=ctx->qualifiedName(); if (ctx->definitionType()==Definition::TypeMember) { MemberDef *md = (MemberDef *)ctx; name.prepend((md->getLanguage()==SrcLangExt_Fortran ? theTranslator->trSubprogram(TRUE,TRUE) : theTranslator->trMember(TRUE,TRUE))+" "); } else // compound type { SrcLangExt lang = ctx->getLanguage(); QCString sep = getLanguageSpecificSeparator(lang); if (sep!="::") { name = substitute(name,"::",sep); } switch (ctx->definitionType()) { case Definition::TypePage: { PageDef *pd = (PageDef *)ctx; if (!pd->title().isEmpty()) { name = theTranslator->trPage(TRUE,TRUE)+" "+pd->title(); } else { name = theTranslator->trPage(TRUE,TRUE)+" "+pd->name(); } } break; case Definition::TypeClass: { ClassDef *cd = (ClassDef *)ctx; name.prepend(cd->compoundTypeString()+" "); } break; case Definition::TypeNamespace: { if (lang==SrcLangExt_Java || lang==SrcLangExt_CSharp) { name = theTranslator->trPackage(name); } else if (lang==SrcLangExt_Fortran) { name.prepend(theTranslator->trModule(TRUE,TRUE)+" "); } else { name.prepend(theTranslator->trNamespace(TRUE,TRUE)+" "); } } break; case Definition::TypeGroup: { GroupDef *gd = (GroupDef *)ctx; if (gd->groupTitle()) { name = theTranslator->trGroup(TRUE,TRUE)+" "+gd->groupTitle(); } else { name.prepend(theTranslator->trGroup(TRUE,TRUE)+" "); } } break; default: break; } } int *pIndex = m_url2IdMap.find(url); if (pIndex==0) { ++m_urlIndex; m_url2IdMap.insert(url,new int(m_urlIndex)); m_urls.insert(m_urlIndex,new URL(name,url)); } else { m_urls.insert(*pIndex,new URL(name,url)); } }
void generatePlantUMLOutput(const char *baseName,const char *outDir,PlantUMLOutputFormat format) { static QCString plantumlJarPath = Config_getString("PLANTUML_JAR_PATH"); QCString pumlExe = "java"; QCString pumlArgs = ""; QStrList &pumlIncludePathList = Config_getList("PLANTUML_INCLUDE_PATH"); char *s=pumlIncludePathList.first(); if (s) { pumlArgs += "-Dplantuml.include.path=\""; pumlArgs += s; s = pumlIncludePathList.next(); } while (s) { pumlArgs += portable_pathListSeparator(); pumlArgs += s; s = pumlIncludePathList.next(); } if (pumlIncludePathList.first()) pumlArgs += "\" "; pumlArgs += "-Djava.awt.headless=true -jar \""+plantumlJarPath+"plantuml.jar\" "; pumlArgs+="-o \""; pumlArgs+=outDir; pumlArgs+="\" "; QCString extension; switch (format) { case PUML_BITMAP: pumlArgs+="-tpng"; extension=".png"; break; case PUML_EPS: pumlArgs+="-teps"; extension=".eps"; break; case PUML_SVG: pumlArgs+="-tsvg"; extension=".svg"; break; } pumlArgs+=" \""; pumlArgs+=baseName; pumlArgs+=".pu\" "; pumlArgs+="-charset " + Config_getString("INPUT_ENCODING") + " "; int exitCode; //printf("*** running: %s %s outDir:%s %s\n",pumlExe.data(),pumlArgs.data(),outDir,outFile); msg("Running PlantUML on generated file %s.pu\n",baseName); portable_sysTimerStart(); if ((exitCode=portable_system(pumlExe,pumlArgs,FALSE))!=0) { err("Problems running PlantUML. Verify that the command 'java -jar \"%splantuml.jar\" -h' works from the command line. Exit code: %d\n", plantumlJarPath.data(),exitCode); } else if (Config_getBool("DOT_CLEANUP")) { QFile(QCString(baseName)+".pu").remove(); } portable_sysTimerStop(); if ( (format==PUML_EPS) && (Config_getBool("USE_PDFLATEX")) ) { QCString epstopdfArgs(maxCmdLine); epstopdfArgs.sprintf("\"%s.eps\" --outfile=\"%s.pdf\"",baseName,baseName); portable_sysTimerStart(); if (exitCode=portable_system("epstopdf",epstopdfArgs)!=0) { err("Problems running epstopdf. Check your TeX installation! Exit code: %d\n",exitCode); } portable_sysTimerStop(); } }
static void generateJSNavTree(const QList<FTVNode> &nodeList) { QCString htmlOutput = Config_getString("HTML_OUTPUT"); QFile f(htmlOutput+"/navtreedata.js"); NavIndexEntryList navIndex; if (f.open(IO_WriteOnly) /*&& fidx.open(IO_WriteOnly)*/) { //FTextStream tidx(&fidx); //tidx << "var NAVTREEINDEX =" << endl; //tidx << "{" << endl; FTextStream t(&f); t << "var NAVTREE =" << endl; t << "[" << endl; t << " [ "; QCString &projName = Config_getString("PROJECT_NAME"); if (projName.isEmpty()) { if (Doxygen::mainPage && !Doxygen::mainPage->title().isEmpty()) // Use title of main page as root { t << "\"" << convertToJSString(Doxygen::mainPage->title()) << "\", "; } else // Use default section title as root { LayoutNavEntry *lne = LayoutDocManager::instance().rootNavEntry()->find(LayoutNavEntry::MainPage); t << "\"" << convertToJSString(lne->title()) << "\", "; } } else // use PROJECT_NAME as root tree element { t << "\"" << convertToJSString(projName) << "\", "; } t << "\"index" << Doxygen::htmlFileExtension << "\", "; // add special entry for index page navIndex.append(new NavIndexEntry("index"+Doxygen::htmlFileExtension,"")); // related page index is written as a child of index.html, so add this as well navIndex.append(new NavIndexEntry("pages"+Doxygen::htmlFileExtension,"")); bool first=TRUE; generateJSTree(navIndex,t,nodeList,1,first); if (first) t << "]" << endl; else t << endl << " ] ]" << endl; t << "];" << endl << endl; // write the navigation index (and sub-indices) navIndex.sort(); int subIndex=0; int elemCount=0; const int maxElemCount=250; //QFile fidx(htmlOutput+"/navtreeindex.js"); QFile fsidx(htmlOutput+"/navtreeindex0.js"); if (/*fidx.open(IO_WriteOnly) &&*/ fsidx.open(IO_WriteOnly)) { //FTextStream tidx(&fidx); FTextStream tsidx(&fsidx); t << "var NAVTREEINDEX =" << endl; t << "[" << endl; tsidx << "var NAVTREEINDEX" << subIndex << " =" << endl; tsidx << "{" << endl; QListIterator<NavIndexEntry> li(navIndex); NavIndexEntry *e; bool first=TRUE; for (li.toFirst(); (e=li.current());) // for each entry { if (elemCount==0) { if (!first) { t << "," << endl; } else { first=FALSE; } t << "\"" << e->url << "\""; } tsidx << "\"" << e->url << "\":[" << e->path << "]"; ++li; if (li.current() && elemCount<maxElemCount-1) tsidx << ","; // not last entry tsidx << endl; elemCount++; if (li.current() && elemCount>=maxElemCount) // switch to new sub-index { tsidx << "};" << endl; elemCount=0; fsidx.close(); subIndex++; fsidx.setName(htmlOutput+"/navtreeindex"+QCString().setNum(subIndex)+".js"); if (!fsidx.open(IO_WriteOnly)) break; tsidx.setDevice(&fsidx); tsidx << "var NAVTREEINDEX" << subIndex << " =" << endl; tsidx << "{" << endl; } } tsidx << "};" << endl; t << endl << "];" << endl; } t << endl << "var SYNCONMSG = '" << theTranslator->trPanelSynchronisationTooltip(FALSE) << "';"; t << endl << "var SYNCOFFMSG = '" << theTranslator->trPanelSynchronisationTooltip(TRUE) << "';"; } ResourceMgr::instance().copyResource("navtree.js",htmlOutput); }
extern "C" KDE_EXPORT int kdemain(int argc, char **argv) { { QCString multiHead = getenv("KDE_MULTIHEAD"); if(multiHead.lower() == "true") { Display *dpy = XOpenDisplay(NULL); if(!dpy) { fprintf(stderr, "%s: FATAL ERROR: couldn't open display %s\n", argv[0], XDisplayName(NULL)); exit(1); } int number_of_screens = ScreenCount(dpy); kicker_screen_number = DefaultScreen(dpy); int pos; QCString display_name = XDisplayString(dpy); XCloseDisplay(dpy); dpy = 0; if((pos = display_name.findRev('.')) != -1) display_name.remove(pos, 10); QCString env; if(number_of_screens != 1) { for(int i = 0; i < number_of_screens; i++) { if(i != kicker_screen_number && fork() == 0) { kicker_screen_number = i; // break here because we are the child process, we don't // want to fork() anymore break; } } env.sprintf("DISPLAY=%s.%d", display_name.data(), kicker_screen_number); if(putenv(strdup(env.data()))) { fprintf(stderr, "%s: WARNING: unable to set DISPLAY environment variable\n", argv[0]); perror("putenv()"); } } } } KGlobal::locale()->setMainCatalogue("kicker"); QCString appname; if(kicker_screen_number == 0) appname = "kicker"; else appname.sprintf("kicker-screen-%d", kicker_screen_number); KAboutData aboutData(appname.data(), I18N_NOOP("KDE Panel"), version, description, KAboutData::License_BSD, I18N_NOOP("(c) 1999-2004, The KDE Team")); aboutData.addAuthor("Aaron J. Seigo", I18N_NOOP("Current maintainer"), "*****@*****.**"); aboutData.addAuthor("Matthias Elter", 0, "*****@*****.**"); aboutData.addAuthor("Matthias Ettrich", 0, "*****@*****.**"); aboutData.addAuthor("Wilco Greven", 0, "*****@*****.**"); aboutData.addAuthor("Rik Hemsley", 0, "*****@*****.**"); aboutData.addAuthor("Daniel M. Duley", 0, "*****@*****.**"); aboutData.addAuthor("Preston Brown", 0, "*****@*****.**"); aboutData.addAuthor("John Firebaugh", 0, "*****@*****.**"); aboutData.addAuthor("Waldo Bastian", I18N_NOOP("Kiosk mode"), "*****@*****.**"); aboutData.addCredit("Jessica Hall", /* I18N_NOOP("KConfigXT") */ 0, "*****@*****.**"); aboutData.addCredit("Stefan Nikolaus", /* I18N_NOOP("Bug fixes") */ 0, "*****@*****.**"); aboutData.addCredit("Benoît Minisini", /* I18N_NOOP("Bug fixes") */ 0, "*****@*****.**"); KCmdLineArgs::init(argc, argv, &aboutData); if(!Kicker::start()) { kdError() << "kicker is already running!" << endl; return 0; } if(signal(SIGTERM, sighandler) == SIG_IGN) signal(SIGTERM, SIG_IGN); if(signal(SIGINT, sighandler) == SIG_IGN) signal(SIGINT, SIG_IGN); if(signal(SIGHUP, sighandler) == SIG_IGN) signal(SIGHUP, SIG_IGN); // send it even before KApplication ctor, because ksmserver will launch another app as soon // as QApplication registers with it DCOPClient *cl = new DCOPClient; cl->attach(); DCOPRef r("ksmserver", "ksmserver"); r.setDCOPClient(cl); r.send("suspendStartup", QCString("kicker")); delete cl; Kicker *kicker = new Kicker; int rv = kicker->exec(); delete kicker; return rv; }
static QCString originalMessageID( const QCString & msgid ) { if ( msgid.isEmpty() ) return QCString(); else return "Original-Message-ID: " + msgid + "\n"; }
TagAnchorInfo(const QCString &f, const QCString &l, const QCString &t=QCString()) : label(l), fileName(f), title(t) {}
void MemberList::writePlainDeclarations(OutputList &ol, ClassDef *cd,NamespaceDef *nd,FileDef *fd, GroupDef *gd, const DefinitionIntf::DefType compoundType, ClassDef *inheritedFrom,const char *inheritId ) { //printf("----- writePlainDeclaration() ----\n"); countDecMembers(); if (numDecMembers()==0) { //printf(" --> no members!\n"); return; // no members in this list } //printf(" --> writePlainDeclaration() numDecMembers()=%d\n", // numDecMembers()); ol.pushGeneratorState(); bool first=TRUE; MemberDef *md; MemberListIterator mli(*this); for ( ; (md=mli.current()); ++mli ) { //printf(">>> Member `%s' type=%d visible=%d\n", // md->name().data(),md->memberType(),md->isBriefSectionVisible()); if ((inheritedFrom==0 || !md->isReimplementedBy(inheritedFrom)) && md->isBriefSectionVisible()) { //printf(">>> rendering\n"); switch(md->memberType()) { case MemberType_Define: // fall through //case MemberType_Prototype: // fall through case MemberType_Typedef: // fall through case MemberType_Variable: // fall through case MemberType_Function: // fall through case MemberType_Signal: // fall through case MemberType_Slot: // fall through case MemberType_DCOP: // fall through case MemberType_Property: // fall through case MemberType_Interface: // fall through case MemberType_Service: // fall through case MemberType_Event: { if (first) ol.startMemberList(),first=FALSE; md->writeDeclaration(ol,cd,nd,fd,gd,m_inGroup,compoundType,inheritedFrom,inheritId); break; } case MemberType_Enumeration: { int enumVars=0; MemberListIterator vmli(*this); MemberDef *vmd; QCString name(md->name()); int i=name.findRev("::"); if (i!=-1) name=name.right(name.length()-i-2); // strip scope (TODO: is this needed?) if (name[0]=='@') // anonymous enum => append variables { for ( ; (vmd=vmli.current()) ; ++vmli) { QCString vtype=vmd->typeString(); if ((vtype.find(name))!=-1) { enumVars++; vmd->setAnonymousEnumType(md); } } } // if this is an anonymous enum and there are variables of this // enum type (i.e. enumVars>0), then we do not show the enum here. if (enumVars==0) // show enum here { //printf("Enum!!\n"); if (first) { ol.startMemberList(); first=FALSE; } ol.startMemberDeclaration(); ol.startMemberItem(md->anchor(),0,inheritId); bool detailsLinkable = md->isDetailedSectionLinkable(); if (!detailsLinkable) { ol.startDoxyAnchor(md->getOutputFileBase(),0,md->anchor(),md->name(),QCString()); } ol.writeString("enum "); ol.insertMemberAlign(); md->writeEnumDeclaration(ol,cd,nd,fd,gd,compoundType); if (!detailsLinkable) { ol.endDoxyAnchor(md->getOutputFileBase(),md->anchor()); } ol.endMemberItem(); if (!md->briefDescription().isEmpty() && Config_getBool("BRIEF_MEMBER_DESC")) { DocRoot *rootNode = validatingParseDoc( md->briefFile(),md->briefLine(), cd,md, md->briefDescription(), TRUE,FALSE,0,TRUE,FALSE ); if (rootNode && !rootNode->isEmpty()) { ol.startMemberDescription(md->anchor()); ol.writeDoc(rootNode,cd,md); if (md->isDetailedSectionLinkable()) { ol.disableAllBut(OutputGenerator::Html); ol.docify(" "); ol.startTextLink(md->getOutputFileBase(), md->anchor()); ol.parseText(theTranslator->trMore()); ol.endTextLink(); ol.enableAll(); } ol.endMemberDescription(); } delete rootNode; } ol.endMemberDeclaration(md->anchor(),inheritId); } md->warnIfUndocumented(); break; } case MemberType_Friend: if (inheritedFrom==0) { if (first) { ol.startMemberList(); first=FALSE; } md->writeDeclaration(ol,cd,nd,fd,gd,m_inGroup,compoundType,inheritedFrom,inheritId); break; } case MemberType_EnumValue: { if (m_inGroup) { //printf("EnumValue!\n"); if (first) ol.startMemberList(),first=FALSE; md->writeDeclaration(ol,cd,nd,fd,gd,m_inGroup,compoundType,inheritedFrom,inheritId); } } break; } } } // handle members that are inside anonymous compounds and for which // no variables of the anonymous compound type exist. if (cd) { MemberListIterator mli(*this); for ( ; (md=mli.current()) ; ++mli ) { if (md->fromAnonymousScope() && !md->anonymousDeclShown()) { md->setFromAnonymousScope(FALSE); //printf("anonymous compound members\n"); if (md->isBriefSectionVisible()) { if (first) { ol.startMemberList(); first=FALSE; } md->writeDeclaration(ol,cd,nd,fd,gd,m_inGroup,compoundType); } md->setFromAnonymousScope(TRUE); } } } if (!first) { ol.endMemberList(); } ol.popGeneratorState(); //printf("----- end writePlainDeclaration() ----\n"); }
void ClangParser::start(const char *fileName,QStrList &filesInTranslationUnit) { static bool clangAssistedParsing = Config_getBool(CLANG_ASSISTED_PARSING); static QStrList &includePath = Config_getList(INCLUDE_PATH); static QStrList clangOptions = Config_getList(CLANG_OPTIONS); static QCString clangCompileDatabase = Config_getList(CLANG_COMPILATION_DATABASE_PATH); if (!clangAssistedParsing) return; //printf("ClangParser::start(%s)\n",fileName); p->fileName = fileName; p->index = clang_createIndex(0, 0); p->curLine = 1; p->curToken = 0; QDictIterator<void> di(Doxygen::inputPaths); int argc=0; std::string error; // load a clang compilation database (https://clang.llvm.org/docs/JSONCompilationDatabase.html) // this only needs to be loaded once, and could be refactored to a higher level function static std::unique_ptr<clang::tooling::CompilationDatabase> db = clang::tooling::CompilationDatabase::loadFromDirectory(clangCompileDatabase.data(), error); int clang_option_len = 0; std::vector<clang::tooling::CompileCommand> command; if (strcmp(clangCompileDatabase, "0") != 0) { if (db == nullptr) { // user specified a path, but DB file was not found err("%s using clang compilation database path of: \"%s\"\n", error.c_str(), clangCompileDatabase.data()); } else { // check if the file we are parsing is in the DB command = db->getCompileCommands(fileName); if (!command.empty() ) { // it's possible to have multiple entries for the same file, so use the last entry clang_option_len = command[command.size()-1].CommandLine.size(); } } } char **argv = (char**)malloc(sizeof(char*)*(4+Doxygen::inputPaths.count()+includePath.count()+clangOptions.count()+clang_option_len)); if (!command.empty() ) { std::vector<std::string> options = command[command.size()-1].CommandLine; // copy each compiler option used from the database. Skip the first which is compiler exe. for (auto option = options.begin()+1; option != options.end(); option++) { argv[argc++] = strdup(option->c_str()); } // this extra addition to argv is accounted for as we are skipping the first entry in argv[argc++]=strdup("-w"); // finally, turn off warnings. } else { // add include paths for input files for (di.toFirst();di.current();++di,++argc) { QCString inc = QCString("-I")+di.currentKey(); argv[argc]=strdup(inc.data()); //printf("argv[%d]=%s\n",argc,argv[argc]); } // add external include paths for (uint i=0;i<includePath.count();i++) { QCString inc = QCString("-I")+includePath.at(i); argv[argc++]=strdup(inc.data()); } // user specified options for (uint i=0;i<clangOptions.count();i++) { argv[argc++]=strdup(clangOptions.at(i)); } // extra options argv[argc++]=strdup("-ferror-limit=0"); argv[argc++]=strdup("-x"); // Since we can be presented with a .h file that can contain C/C++ or // Objective C code and we need to configure the parser before knowing this, // we use the source file to detected the language. Detection will fail if you // pass a bunch of .h files containing ObjC code, and no sources :-( SrcLangExt lang = getLanguageFromFileName(fileName); if (lang==SrcLangExt_ObjC || p->detectedLang!=ClangParser::Private::Detected_Cpp) { QCString fn = fileName; if (p->detectedLang==ClangParser::Private::Detected_Cpp && (fn.right(4).lower()==".cpp" || fn.right(4).lower()==".cxx" || fn.right(3).lower()==".cc" || fn.right(2).lower()==".c")) { // fall back to C/C++ once we see an extension that indicates this p->detectedLang = ClangParser::Private::Detected_Cpp; } else if (fn.right(3).lower()==".mm") // switch to Objective C++ { p->detectedLang = ClangParser::Private::Detected_ObjCpp; } else if (fn.right(2).lower()==".m") // switch to Objective C { p->detectedLang = ClangParser::Private::Detected_ObjC; } } switch(p->detectedLang) { case ClangParser::Private::Detected_Cpp: argv[argc++]=strdup("c++"); break; case ClangParser::Private::Detected_ObjC: argv[argc++]=strdup("objective-c"); break; case ClangParser::Private::Detected_ObjCpp: argv[argc++]=strdup("objective-c++"); break; } // provide the input and and its dependencies as unsaved files so we can // pass the filtered versions argv[argc++]=strdup(fileName); } static bool filterSourceFiles = Config_getBool(FILTER_SOURCE_FILES); //printf("source %s ----------\n%s\n-------------\n\n", // fileName,p->source.data()); uint numUnsavedFiles = filesInTranslationUnit.count()+1; p->numFiles = numUnsavedFiles; p->sources = new QCString[numUnsavedFiles]; p->ufs = new CXUnsavedFile[numUnsavedFiles]; p->sources[0] = detab(fileToString(fileName,filterSourceFiles,TRUE)); p->ufs[0].Filename = strdup(fileName); p->ufs[0].Contents = p->sources[0].data(); p->ufs[0].Length = p->sources[0].length(); QStrListIterator it(filesInTranslationUnit); uint i=1; for (it.toFirst();it.current() && i<numUnsavedFiles;++it,i++) { p->fileMapping.insert(it.current(),new uint(i)); p->sources[i] = detab(fileToString(it.current(),filterSourceFiles,TRUE)); p->ufs[i].Filename = strdup(it.current()); p->ufs[i].Contents = p->sources[i].data(); p->ufs[i].Length = p->sources[i].length(); } // let libclang do the actual parsing p->tu = clang_parseTranslationUnit(p->index, 0, argv, argc, p->ufs, numUnsavedFiles, CXTranslationUnit_DetailedPreprocessingRecord); // free arguments for (int i=0;i<argc;++i) { free(argv[i]); } free(argv); if (p->tu) { // filter out any includes not found by the clang parser determineInputFilesInSameTu(filesInTranslationUnit); // show any warnings that the compiler produced for (uint i=0, n=clang_getNumDiagnostics(p->tu); i!=n; ++i) { CXDiagnostic diag = clang_getDiagnostic(p->tu, i); CXString string = clang_formatDiagnostic(diag, clang_defaultDiagnosticDisplayOptions()); err("%s [clang]\n",clang_getCString(string)); clang_disposeString(string); clang_disposeDiagnostic(diag); } // create a source range for the given file QFileInfo fi(fileName); CXFile f = clang_getFile(p->tu, fileName); CXSourceLocation fileBegin = clang_getLocationForOffset(p->tu, f, 0); CXSourceLocation fileEnd = clang_getLocationForOffset(p->tu, f, p->ufs[0].Length); CXSourceRange fileRange = clang_getRange(fileBegin, fileEnd); // produce a token stream for the file clang_tokenize(p->tu,fileRange,&p->tokens,&p->numTokens); // produce cursors for each token in the stream p->cursors=new CXCursor[p->numTokens]; clang_annotateTokens(p->tu,p->tokens,p->numTokens,p->cursors); } else { p->tokens = 0; p->numTokens = 0; p->cursors = 0; err("clang: Failed to parse translation unit %s\n",fileName); } }
Atom KDETrayProxy::makeSelectionAtom() { return XInternAtom(qt_xdisplay(), "_NET_SYSTEM_TRAY_S" + QCString().setNum(qt_xscreen()), False); }
extern "C" KDE_EXPORT int kdemain( int argc, char **argv ) { // here we go, construct the Kate version QString kateVersion = KateApp::kateVersion(); KAboutData aboutData ("kate", I18N_NOOP("Kate"), kateVersion.latin1(), I18N_NOOP( "Kate - Advanced Text Editor" ), KAboutData::License_LGPL_V2, I18N_NOOP( "(c) 2000-2005 The Kate Authors" ), 0, "http://kate.kde.org"); aboutData.addAuthor ("Christoph Cullmann", I18N_NOOP("Maintainer"), "*****@*****.**", "http://www.babylon2k.de"); aboutData.addAuthor ("Anders Lund", I18N_NOOP("Core Developer"), "*****@*****.**", "http://www.alweb.dk"); aboutData.addAuthor ("Joseph Wenninger", I18N_NOOP("Core Developer"), "*****@*****.**","http://stud3.tuwien.ac.at/~e9925371"); aboutData.addAuthor ("Hamish Rodda",I18N_NOOP("Core Developer"), "*****@*****.**"); aboutData.addAuthor ("Waldo Bastian", I18N_NOOP( "The cool buffersystem" ), "*****@*****.**" ); aboutData.addAuthor ("Charles Samuels", I18N_NOOP("The Editing Commands"), "*****@*****.**"); aboutData.addAuthor ("Matt Newell", I18N_NOOP("Testing, ..."), "*****@*****.**"); aboutData.addAuthor ("Michael Bartl", I18N_NOOP("Former Core Developer"), "*****@*****.**"); aboutData.addAuthor ("Michael McCallum", I18N_NOOP("Core Developer"), "*****@*****.**"); aboutData.addAuthor ("Jochen Wilhemly", I18N_NOOP( "KWrite Author" ), "*****@*****.**" ); aboutData.addAuthor ("Michael Koch",I18N_NOOP("KWrite port to KParts"), "*****@*****.**"); aboutData.addAuthor ("Christian Gebauer", 0, "*****@*****.**" ); aboutData.addAuthor ("Simon Hausmann", 0, "*****@*****.**" ); aboutData.addAuthor ("Glen Parker",I18N_NOOP("KWrite Undo History, Kspell integration"), "*****@*****.**"); aboutData.addAuthor ("Scott Manson",I18N_NOOP("KWrite XML Syntax highlighting support"), "*****@*****.**"); aboutData.addAuthor ("John Firebaugh",I18N_NOOP("Patches and more"), "*****@*****.**"); aboutData.addAuthor ("Dominik Haumann", I18N_NOOP("Developer & Highlight wizard"), "*****@*****.**"); aboutData.addCredit ("Matteo Merli",I18N_NOOP("Highlighting for RPM Spec-Files, Perl, Diff and more"), "*****@*****.**"); aboutData.addCredit ("Rocky Scaletta",I18N_NOOP("Highlighting for VHDL"), "*****@*****.**"); aboutData.addCredit ("Yury Lebedev",I18N_NOOP("Highlighting for SQL"),""); aboutData.addCredit ("Chris Ross",I18N_NOOP("Highlighting for Ferite"),""); aboutData.addCredit ("Nick Roux",I18N_NOOP("Highlighting for ILERPG"),""); aboutData.addCredit ("Carsten Niehaus", I18N_NOOP("Highlighting for LaTeX"),""); aboutData.addCredit ("Per Wigren", I18N_NOOP("Highlighting for Makefiles, Python"),""); aboutData.addCredit ("Jan Fritz", I18N_NOOP("Highlighting for Python"),""); aboutData.addCredit ("Daniel Naber","",""); aboutData.addCredit ("Roland Pabel",I18N_NOOP("Highlighting for Scheme"),""); aboutData.addCredit ("Cristi Dumitrescu",I18N_NOOP("PHP Keyword/Datatype list"),""); aboutData.addCredit ("Carsten Pfeiffer", I18N_NOOP("Very nice help"), ""); aboutData.addCredit (I18N_NOOP("All people who have contributed and I have forgotten to mention"),"",""); aboutData.setTranslator(I18N_NOOP2("NAME OF TRANSLATORS","Your names"), I18N_NOOP2("EMAIL OF TRANSLATORS","Your emails")); // command line args init and co KCmdLineArgs::init (argc, argv, &aboutData); KCmdLineArgs::addCmdLineOptions (options); KCmdLineArgs::addTempFileOption(); KateApp::addCmdLineOptions (); // get our command line args ;) KCmdLineArgs* args = KCmdLineArgs::parsedArgs(); // now, first try to contact running kate instance if needed if ( args->isSet("use") || (::getenv("KATE_PID")!=0) ) { DCOPClient client; client.attach (); // get all attached clients ;) QCStringList allClients = client.registeredApplications(); // search for a kate app client, use the first found QCString kateApp; if ( args->isSet("start") ) { for (unsigned int i=0; i < allClients.count(); i++) { if (allClients[i] == "kate" || allClients[i].left(5) == "kate-") { DCOPRef ref( allClients[i], "KateApplication" ); QString s = ref.call( "session" ); if ( QString(args->getOption("start")) == s ) { kateApp = allClients[i]; break; } } } } else if ( (args->isSet("pid")) || (::getenv("KATE_PID") !=0 ) ) { QCString tryApp; if ( args->isSet("pid") ) tryApp = args->getOption("pid"); else tryApp = ::getenv("KATE_PID"); if ( client.isApplicationRegistered( tryApp.prepend("kate-") ) ) kateApp = tryApp; } else { for (unsigned int i=0; i < allClients.count(); ++i) { if (allClients[i] == "kate" || allClients[i].left(5) == "kate-") { kateApp = allClients[i]; break; } } } // found a matching kate client ;) if (!kateApp.isEmpty()) { kdDebug () << "kate app: " << kateApp << endl; // make kdeinit happy client.registerAs( "kate" ); DCOPRef kRef (kateApp, "KateApplication"); if (args->isSet ("start")) kRef.call( "activateSession", QString (args->getOption("start")) ); QString enc = args->isSet("encoding") ? args->getOption("encoding") : QCString(""); bool tempfileSet = KCmdLineArgs::isTempFileSet(); for (int z=0; z<args->count(); z++) kRef.call( "openURL", args->url(z), enc, tempfileSet ); if( args->isSet( "stdin" ) ) { QTextIStream input(stdin); // set chosen codec QTextCodec *codec = args->isSet("encoding") ? QTextCodec::codecForName(args->getOption("encoding")) : 0; if (codec) input.setCodec (codec); QString line; QString text; do { line = input.readLine(); text.append( line + "\n" ); } while( !line.isNull() ); kRef.call( "openInput", text ); } int line = 0; int column = 0; bool nav = false; if (args->isSet ("line")) { line = args->getOption ("line").toInt(); nav = true; } if (args->isSet ("column")) { column = args->getOption ("column").toInt(); nav = true; } if (nav) kRef.call( "setCursor", line, column ); // since the user tried to open a document, let us assume [s]he // wants to see that document. // ### what to do about the infamous focus stealing prevention? uint mwn = kRef.call("activeMainWindowNumber"); QCString smwn; DCOPRef wRef( kateApp, QCString( "__KateMainWindow#") + smwn.setNum(mwn) ); if ( wRef.call("minimized") ) { if ( wRef.call( "maximized" ) ) wRef.call( "maximize" ); else wRef.call("restore"); } wRef.call( "raise" ); // stop startup notification KStartupInfo::appStarted( ); return 0; } } // construct the real kate app object ;) KateApp app (args); // app execution should already end :) if (app.shouldExit()) { return 0; } // execute ourself ;) return app.exec(); }