bool Helper::handleGetSaveX( bool url )
    {
    if( !readArguments( 4 ))
        return false;
    QString startDir = getArgument();
    QString filter = getArgument().replace("/", "\\/"); // TODO: ignored
    int selectFilter = getArgument().toInt();
    QString title = getArgument();
    long wid = getArgumentParent();
    if( !allArgumentsUsed())
        return false;

    if (title.isEmpty())
        title = i18n("Save As");

    // TODO: confirm overwrite
    if (url) {
        QUrl result = QFileDialog::getSaveFileUrl(nullptr, title, startDir);
        if (result.isValid()) {
            outputLine(QStringLiteral("0"));
            outputLine(result.url());
            return true;
        }
    } else {
        QString result = QFileDialog::getSaveFileName(nullptr, title, startDir);
        if (!result.isEmpty()) {
            KRecentDocument::add(QUrl::fromLocalFile(result));
            outputLine(QStringLiteral("0"));
            outputLine(result);
            return true;
        }
    }

    return false;
    }
bool Helper::handleGetDirectoryX( bool url )
    {
    if( !readArguments( 2 ))
        return false;
    QString startDir = getArgument();
    QString title = getArgument();
    long wid = getArgumentParent();
    if( !allArgumentsUsed())
        return false;

    if (url) {
        QUrl result = QFileDialog::getExistingDirectoryUrl(nullptr, title, startDir);
        if (result.isValid()) {
            outputLine(result.url());
            return true;
        }
    } else {
        QString result = QFileDialog::getExistingDirectory(nullptr, title, startDir);
        if (!result.isEmpty()) {
            outputLine(QUrl::fromLocalFile(result).url());
            return true;
        }
    }

    return false;
    }
Example #3
0
void outputSuduku (US* suduku, US size) {
    US row;
    outputLine(size);
    for ( row = 0 ; row < size ; row++ ) {
        outputRow(&suduku[row*size], size);
        outputLine(size);
    };
}
Example #4
0
static void outputPartSuduku (US *suduku, US size, US currentRow, US currentCol) {
    US i;
    outputLine(size);
    for ( i=0 ; i < currentRow ; i++ ) {
	 outputRow(&(suduku[i*size]), size);
	 printf("\b");
	 outputLine(size);
    };
    outputRow(&(suduku[currentRow*size]), currentCol);
}
bool Helper::writeMimeInfo( QMimeType mime )
    {
    KService::Ptr service = KMimeTypeTrader::self()->preferredService( mime.name());
    if( service )
        {
        outputLine( mime.name());
        outputLine( mime.comment());
        outputLine( service->name());
        return true;
        }
    return false;
    }
bool Helper::handleAppsDialog()
    {
    if( !readArguments( 1 ))
        return false;
    QString title = getArgument();
    long wid = getArgumentParent();
    if( !allArgumentsUsed())
        return false;
    KOpenWithDialog dialog( NULL );
    if( !title.isEmpty())
        dialog.setWindowTitle( title );
    dialog.hideNoCloseOnExit();
    dialog.hideRunInTerminal(); // TODO
    if( wid != 0 )
        KWindowSystem::setMainWindow( &dialog, wid );
    if( dialog.exec())
        {
        KService::Ptr service = dialog.service();
        QString command;
        if( service )
            command = service->exec();
        else if( !dialog.text().isEmpty())
            command = dialog.text();
        else
            return false;
        command = command.split( " " ).first(); // only the actual command
        command = QStandardPaths::findExecutable(command);
        if( command.isEmpty())
            return false;
        outputLine( QUrl::fromUserInput( command ).url());
        return true;
        }
    return false;
    }
Example #7
0
void Connection::processStream(const QDomDocument &xml)
{
    if (xml.documentElement().attribute("encoding") == "base64") {
        /* We ignore the output type for now
        KDevelop::IRunProvider::OutputTypes outputType;
        if (xml->attributes().value("type") == "stdout") {
            outputType = KDevelop::IRunProvider::StandardOutput;
        } else if (xml->attributes().value("type") == "stderr") {
            outputType = KDevelop::IRunProvider::StandardError;
        } else {
            kWarning() << "unknown output type" << xml->attributes().value("type");
            return;
        }
        */

        QString c = m_codec->toUnicode(QByteArray::fromBase64(xml.documentElement().text().toAscii()));
        //kDebug() << c;
        emit output(c);
        m_outputLine += c;
        int pos = m_outputLine.indexOf('\n');
        if (pos != -1) {
            emit outputLine(m_outputLine.left(pos));
            m_outputLine = m_outputLine.mid(pos+1);
        }
    } else {
        kWarning() << "unknown encoding" << xml.documentElement().attribute("encoding");
    }
}
bool Helper::handleGetOpenX( bool url )
    {
    if( !readArguments( 4 ))
        return false;
    QString startDir = getArgument();
    QString filter = getArgument().replace("/", "\\/"); // TODO: not used
    int selectFilter = getArgument().toInt();
    QString title = getArgument();
    bool multiple = isArgument( "MULTIPLE" );
    long wid = getArgumentParent();
    if( !allArgumentsUsed())
        return false;

    if (title.isEmpty())
        title = i18n("Open");

    if (url) {
        QList<QUrl> result;
        if (multiple)
            result = QFileDialog::getOpenFileUrls(nullptr, title, startDir);
        else
            result << QFileDialog::getOpenFileUrl(nullptr, title, startDir);
        result.removeAll(QUrl());
        if (!result.isEmpty()) {
            outputLine(QStringLiteral("0")); // filter is not implemented, so always 0 (All Files)
            for (const QUrl &url : result)
                outputLine(url.url());
            return true;
        }

    } else {
        QStringList result;
        if (multiple)
            result = QFileDialog::getOpenFileNames(nullptr, title, startDir);
        else
            result << QFileDialog::getOpenFileName(nullptr, title, startDir);
        result.removeAll(QString());
        if (!result.isEmpty()) {
            outputLine(QStringLiteral("0"));
            for (const QString &str : result)
                outputLine(str);
            return true;
        }
    }

    return false;
    }
Example #9
0
static void runDir(MaQueue *q)
{
    MaConn          *conn;
    MaResponse      *resp;
    MaRequest       *req;
    MprList         *list;
    MprDirEntry     *dp;
    Dir             *dir;
    cchar           *filename;
    uint            nameSize;
    int             next;

    conn = q->conn;
    req = conn->request;
    resp = conn->response;
    dir = q->stage->stageData;

    filename = resp->filename;
    mprAssert(filename);

    maDontCacheResponse(conn);
    maSetHeader(conn, 0, "Last-Modified", req->host->currentDate);
    maPutForService(q, maCreateHeaderPacket(q), 0);

    parseQuery(conn);

    list = mprGetPathFiles(conn, filename, 1);
    if (list == 0) {
        maWrite(q, "<h2>Can't get file list</h2>\r\n");
        outputFooter(q);
        return;
    }

    if (dir->pattern) {
        filterDirList(conn, list);
    }

    sortList(conn, list);

    /*
     *  Get max filename
     */
    nameSize = 0;
    for (next = 0; (dp = mprGetNextItem(list, &next)) != 0; ) {
        nameSize = max((int) strlen(dp->name), nameSize);
    }
    nameSize = max(nameSize, 22);

    outputHeader(q, req->url, nameSize);
    for (next = 0; (dp = mprGetNextItem(list, &next)) != 0; ) {
        outputLine(q, dp, filename, nameSize);
    }
    outputFooter(q);

    maPutForService(q, maCreateEndPacket(conn), 1);

    mprFree(list);
}
Example #10
0
/*
    Start the request (and complete it)
 */
static void startDir(HttpQueue *q)
{
    HttpConn        *conn;
    HttpTx          *tx;
    HttpRx          *rx;
    MprList         *list;
    MprDirEntry     *dp;
    HttpDir         *dir;
    cchar           *path;
    uint            nameSize;
    int             next;

    conn = q->conn;
    rx = conn->rx;
    tx = conn->tx;
    if ((dir = conn->reqData) == 0) {
        httpError(conn, HTTP_CODE_INTERNAL_SERVER_ERROR, "Cannot get directory listing");
        return;
    }
    assert(tx->filename);

    if (!(rx->flags & (HTTP_GET | HTTP_HEAD))) {
        httpError(conn, HTTP_CODE_BAD_METHOD, "Bad method");
        return;
    }
    httpSetContentType(conn, "text/html");
    httpSetHeaderString(conn, "Cache-Control", "no-cache");
    httpSetHeaderString(conn, "Last-Modified", conn->http->currentDate);
    parseQuery(conn);

    if ((list = mprGetPathFiles(tx->filename, MPR_PATH_RELATIVE)) == 0) {
        httpWrite(q, "<h2>Cannot get file list</h2>\r\n");
        outputFooter(q);
        return;
    }
    if (dir->pattern) {
        filterDirList(conn, list);
    }
    sortList(conn, list);
    /*
        Get max filename size
     */
    nameSize = 0;
    for (next = 0; (dp = mprGetNextItem(list, &next)) != 0; ) {
        nameSize = max((int) strlen(dp->name), nameSize);
    }
    nameSize = max(nameSize, 22);

    path = rx->route->prefix ? sjoin(rx->route->prefix, rx->pathInfo, NULL) : rx->pathInfo;
    outputHeader(q, path, nameSize);
    for (next = 0; (dp = mprGetNextItem(list, &next)) != 0; ) {
        outputLine(q, dp, tx->filename, nameSize);
    }
    outputFooter(q);
    httpFinalize(conn);
}
Example #11
0
void KSircIODCC::cancelTransfer(QString filename)
{
  if(DlgList[filename]){
    emit outputLine(DCCStatus[filename]->cancelMessage);
    delete DlgList[filename];
    DlgList.remove(filename);
    delete DCCStatus[filename];
    DCCStatus.remove(filename);
  }
}
Example #12
0
 /*
  * run the test case
  * return 0 for pass. -1 for fail.
  */
 inline int runTestCase( TestCase & test, TestContext & context, std::ostream & log)
 {
   int rst = 0;
   try {
     test.run(context);
     log << test.name() << " Passed " << std::endl;
     rst = 0;
   }
   catch (XTestFailure& e) {
     log << outputLine(e.m_file, e.m_line) << e.what() << '\n' << "FAILED: ";
     rst = -1;
   }
   catch (std::exception& e) {
     log << outputLine(__FILE__, __LINE__)
         << "caught standard exception - " << e.what() << '\n'
         << "FAILED: ";
     rst = -1;
   }
   return rst;
 }
bool Helper::handleGetFromType()
    {
    if( !readArguments( 1 ))
        return false;
    QString type = getArgument();
    if( !allArgumentsUsed())
        return false;
    QMimeType mime = QMimeDatabase().mimeTypeForName(type);
    if (mime.isValid()) return writeMimeInfo(mime);
    // firefox also asks for protocol handlers using getfromtype
    QString app = getAppForProtocol( type );
    if( !app.isEmpty())
        {
        outputLine( type );
        outputLine( type ); // TODO probably no way to find a good description
        outputLine( app );
        return true;
        }
    return false;
    }
bool Helper::handleGetDefaultFeedReader()
    {
    if( !readArguments( 0 ))
        return false;
    // firefox wants the full path
    QString reader = QStandardPaths::findExecutable("akregator"); // TODO there is no KDE setting for this
    if( !reader.isEmpty())
        {
        outputLine( reader );
        return true;
        }
    return false;
    }
Example #15
0
void ExtraRptDumpReport(        // DUMP REPORT INTO FILE
    const char *name )          // - name to use for generating file name
{
    RPTREG *reg;
    FILE *fp;
    char *base;
    auto char make_buff[_MAX_PATH];
    auto char split_buff[_MAX_PATH2];

    _splitpath2( name, split_buff, NULL, NULL, &base, NULL );
    _makepath( make_buff, NULL, NULL, base, ".rpt" );
    fp = fopen( make_buff, "w" );
    if( fp == NULL ) {
        return;
    }
    outputLine( fp, "" );
    outputLine( fp, "Statistics Report" );
    outputLine( fp, "=================" );
    outputLine( fp, "" );
    RingIterBeg( reportList, reg ) {
        (reg->base.processor)( fp, reg );
    } RingIterEnd( reg )
Example #16
0
static void processDir(HttpQueue *q)
{
    HttpConn        *conn;
    HttpTx          *tx;
    HttpRx          *rx;
    MprList         *list;
    MprDirEntry     *dp;
    Dir             *dir;
    uint            nameSize;
    int             next;

    conn = q->conn;
    rx = conn->rx;
    tx = conn->tx;
    dir = conn->data;

    mprLog(5, "processDir");
    mprAssert(tx->filename);

    httpSetHeaderString(conn, "Cache-Control", "no-cache");
    httpSetHeaderString(conn, "Last-Modified", conn->http->currentDate);
    parseQuery(conn);

    list = mprGetPathFiles(tx->filename, 1);
    if (list == 0) {
        httpWrite(q, "<h2>Can't get file list</h2>\r\n");
        outputFooter(q);
        return;
    }
    if (dir->pattern) {
        filterDirList(conn, list);
    }
    sortList(conn, list);

    /*
        Get max filename
     */
    nameSize = 0;
    for (next = 0; (dp = mprGetNextItem(list, &next)) != 0; ) {
        nameSize = max((int) strlen(dp->name), nameSize);
    }
    nameSize = max(nameSize, 22);

    outputHeader(q, rx->pathInfo, nameSize);
    for (next = 0; (dp = mprGetNextItem(list, &next)) != 0; ) {
        outputLine(q, dp, tx->filename, nameSize);
    }
    outputFooter(q);
    httpFinalize(conn);
}
bool Helper::handleGetProxy()
    {
    if( !readArguments( 1 ))
        return false;
    QUrl url = QUrl::fromUserInput( getArgument());
    if( !allArgumentsUsed())
        return false;
    QString proxy;
    KProtocolManager::slaveProtocol( url, proxy ); 
    if( proxy.isEmpty() || proxy == "DIRECT" ) // TODO return DIRECT if empty?
        {
        outputLine( "DIRECT" );
        return true;
        }
    QUrl proxyurl = QUrl::fromUserInput( proxy );
    if( proxyurl.isValid())
        { // firefox wants this format
        outputLine( "PROXY" " " + proxyurl.host() + ":" + QString::number( proxyurl.port()));
        // TODO there is also "SOCKS " type
        return true;
        }
    return false;
    }
Example #18
0
//------------------------------------------------------------------------------
bool Console::execute(const std::string& cmdLine /*= ""*/) {
  std::string line = cmdLine.empty() ? mUi->getCmdLine() : cmdLine;
  StringUtil::trim(line);
  if (line.empty()) return false;

  sgLogger.logMessage(
      "************************************************************");
  sgLogger.logMessage("executing command \"" + line + "\"");

  fakeOutputDirAndCmd(line);
  mCmdHistory->push(line);

  mUi->setCmdLine("");

  boost::regex reCmd2("^\\s*(\\w+)(\\s*.*)$");
  boost::smatch m;
  if (boost::regex_match(line, m, reCmd2)) {
    Command* cmd = sgCmdLib.createCommand(m[1]);
    if (cmd) {
      cmd->setArgsAndOptions(m[2]);
      if (cmd->execute()) {
        sgLogger.logMessage("finished executing command \"" + line + "\"");
        sgLogger.logMessage(
            "************************************************************");
        return true;
      }
    } else {
      outputLine("unknown command : " + m[1]);
    }
  } else {
    outputLine("unknown input");
  }
  sgLogger.logMessage("failed executing command \"" + line + "\"");
  sgLogger.logMessage(
      "************************************************************");
  return false;
}
bool Helper::handleGetAppDescForScheme()
    {
    if( !readArguments( 1 ))
        return false;
    QString scheme = getArgument();
    if( !allArgumentsUsed())
        return false;
    QString app = getAppForProtocol( scheme );
    if( !app.isEmpty())
        {
        outputLine( app );
        return true;
        }
    return false;
    }
Example #20
0
void DebugSession::incomingConnection()
{
    kDebug();
    QTcpSocket* client = m_server->nextPendingConnection();

    if (m_connection) {
        m_connection->disconnect();
        m_connection->deleteLater();
        m_connection = 0;
    }

    m_connection = new Connection(client, this);
    connect(m_connection, SIGNAL(output(QString)), SIGNAL(output(QString)));
    connect(m_connection, SIGNAL(outputLine(QString)), SIGNAL(outputLine(QString)));
    connect(m_connection, SIGNAL(initDone(QString)), SIGNAL(initDone(QString)));
    connect(m_connection, SIGNAL(stateChanged(KDevelop::IDebugSession::DebuggerState)), SIGNAL(stateChanged(KDevelop::IDebugSession::DebuggerState)));
    connect(m_connection, SIGNAL(stateChanged(KDevelop::IDebugSession::DebuggerState)), SLOT(_stateChanged(KDevelop::IDebugSession::DebuggerState)));
    connect(m_connection, SIGNAL(currentPositionChanged(KUrl, int)), SLOT(currentPositionChanged(KUrl,int)));
    connect(m_connection, SIGNAL(closed()), SLOT(connectionClosed()));

    if (!m_acceptMultipleConnections) {
        closeServer();
    }
}
Example #21
0
void KSircIODCC::forgetFile()
{
  QString text = pending->fileListing()->text(pending->fileListing()->currentItem());
  int pos = text.find(" ", 0);
  QString nick = text.mid(0, pos);
  pos = text.find(" ", pos+1) + 1;
  QString filename = text.mid(pos, text.length() - pos);
  QString command = "/dcc close get " + nick + " " + filename + "\n";
  emit outputLine(command);
  for(uint i = 0; i < pending->fileListing()->count(); i++)
    if(QString(pending->fileListing()->text(i)) == (nick + " offered " + filename))
      pending->fileListing()->removeItem(i);

  if(pending->fileListing()->count() == 0)
     pending->hide();

}
Example #22
0
void SearchIndex::getRecord(int offset){
    //--------------------------------------------------------------
    //Preconditions: An integer is passed to the method
    //
    //Postconditions: The record referenced by the passed integer is
    //                printed to the screen
    //
    //Variables used: inputFile: reference to an input file stream
    //                &item reference to an Item object
    //--------------------------------------------------------------
    
    Item item;
    
    fstream inputFile("prog5bin.dat", ios::in|ios::binary);
    inputFile.seekg(offset*sizeof(item));
    
    inputFile.read(reinterpret_cast<char * >(&item), sizeof(Item));
    outputLine(item);
    inputFile.close();
}
Example #23
0
File: sig.c Project: aosm/boot
void
parseLine(char *line)
{
    char *paren, *parenEnd;
    char *ident, *identEnd;
    char *arglist, *arglistEnd;
    char *function;
    
    paren = strchr(line, '(');
    if (paren == NULL)
	goto syntax_error;
    for (identEnd = paren - 1; !isIdentifier(*identEnd); identEnd--)
	continue;
    for (ident = identEnd; isIdentifier(*ident); ident--)
	continue;
    ident++;
    *++identEnd = '\0';
    paren++;
    parenEnd = strchr(paren, ')');
    if (parenEnd == NULL)
	goto syntax_error;
    *parenEnd = '\0';

    arglist = parenEnd + 1;
    while (isspace(*arglist))
	arglist++;
    arglistEnd = strchr(arglist, ';');
    if (arglistEnd == NULL)
	goto syntax_error;
    *arglistEnd = '\0';
    
    function = strdup(ident);
    *ident = '\0';
    outputLine(line, function, paren, arglist);
    free(function);
    return;

syntax_error:
    fprintf(stderr, "Syntax error at line %d\n",lineNumber);
    return;
}
Example #24
0
void outputArray (pixel **array, int altura, int largura, int indice) { /* Imprime a grade */
  int i;
    
  for (i = 0; i < altura; i ++) /* Imprime cada linha, de trĂ¡s para frente */
    outputLine(array[(i+indice)%altura], largura);
}
Example #25
0
void KSircIOLAG::timerEvent ( QTimerEvent * )
{
  QString cmd = "/lag\n";
  emit outputLine(cmd);
}
Example #26
0
//------------------------------------------------------------------------------
void Console::fakeOutputDirAndCmd(const std::string& cmdLine) {
  outputLine(mDir->getFullPath() + " " + cmdLine);
}
Example #27
0
int inputLoop(){
	char * buffer = malloc(sizeof(char) * BUFFER_SIZE);
	rInput = 1;
	while(rInput){
		clearBuffer(buffer);
		cleanInputLine();
		char * line = readLine(buffer,BUFFER_SIZE);
		if(line){
			//Analyse and do something with this line...
			if(!strcmp(line,"help")){
				outputLine(HELP_MAIN);
				continue;
			}
			if(!strncmp(line,"help",4)){
				//something was called with help
				line += 5;
				if(!strcmp(line,"new")){
					outputLine(HELP_NEW);
				}
				if(!strcmp(line,"quit")){
					outputLine(HELP_QUIT);
				}
				if(!strcmp(line,"rnew")){
					outputLine(HELP_RNEW);
				}
				if(!strcmp(line,"autonew")){
					outputLine(HELP_AUTONEW);
				}
				// ... more help
				continue;
			}
			// NEW PASSENGER
			if(!strncmp(line,"new",3)){
				line += 4;
				int a, b, c = 1;
				sscanf(line,"%d %d %d",&a,&b,&c);
				while(c--){
					createNew(a,b);
				}
				continue;
			}
			//NEW RANDOM PASSENGER:
			if(!strncmp(line,"rnew",4)){
				line += 5;
				int a = 1;
				sscanf(line,"%d",&a);
				createRandom(a);
			}
			if(!strncmp(line,"autonew",7)){
				line += 8;
				if(!strcmp(line,"on") || !strcmp(line,"off")){
					toggleAutonew(*(line+1) == 'n');
				} else {
					outputLine(HELP_AUTONEW);
				}
				continue;
			}
			// QUIT
			if(!strcmp(line,"quit")){
				stopInputLoop();
				continue;
			}
		}
	}
	free(buffer);
	return rInput;
}
void Helper::readCommand()
    {
    QString command = readLine();
    if( input.atEnd())
        {
#ifdef DEBUG_KDE
        QTextStream( stderr ) << "EOF, existing." << endl;
#endif
        QCoreApplication::exit();
        return;
        }
#ifdef DEBUG_KDE
    QTextStream( stderr ) << "COMMAND:" << command << endl;
#endif
    bool status;
    if( command == "CHECK" )
        status = handleCheck();
    else if( command == "GETPROXY" )
        status = handleGetProxy();
    else if( command == "HANDLEREXISTS" )
        status = handleHandlerExists();
    else if( command == "GETFROMEXTENSION" )
        status = handleGetFromExtension();
    else if( command == "GETFROMTYPE" )
        status = handleGetFromType();
    else if( command == "GETAPPDESCFORSCHEME" )
        status = handleGetAppDescForScheme();
    else if( command == "APPSDIALOG" )
        status = handleAppsDialog();
    else if( command == "GETOPENFILENAME" )
        status = handleGetOpenX( false );
    else if( command == "GETOPENURL" )
        status = handleGetOpenX( true );
    else if( command == "GETSAVEFILENAME" )
        status = handleGetSaveX( false );
    else if( command == "GETSAVEURL" )
        status = handleGetSaveX( true );
    else if( command == "GETDIRECTORYFILENAME" )
        status = handleGetDirectoryX( false );
    else if( command == "GETDIRECTORYURL" )
        status = handleGetDirectoryX( true );
    else if( command == "OPEN" )
        status = handleOpen();
    else if( command == "REVEAL" )
        status = handleReveal();
    else if( command == "RUN" )
        status = handleRun();
    else if( command == "GETDEFAULTFEEDREADER" )
        status = handleGetDefaultFeedReader();
    else if( command == "OPENMAIL" )
        status = handleOpenMail();
    else if( command == "OPENNEWS" )
        status = handleOpenNews();
    else if( command == "ISDEFAULTBROWSER" )
        status = handleIsDefaultBrowser();
    else if( command == "SETDEFAULTBROWSER" )
        status = handleSetDefaultBrowser();
    else if( command == "DOWNLOADFINISHED" )
        status = handleDownloadFinished();
    else
        {
        QTextStream( stderr ) << "Unknown command for KDE helper: " << command << endl;
        status = false;
        }
    // status done as \1 (==ok) and \0 (==not ok), because otherwise this cannot happen
    // in normal data (\ is escaped otherwise)
    outputLine( status ? "\\1" : "\\0", false ); // do not escape
    }