Exemplo n.º 1
0
void KCMKMailSummary::initFolders()
{
  DCOPRef kmail( "kmail", "KMailIface" );

  QStringList folderList;
  kmail.call( "folderList" ).get( folderList );

  mFolderView->clear();
  mFolderMap.clear();

  QStringList::Iterator it;
  for ( it = folderList.begin(); it != folderList.end(); ++it ) {
    QString displayName;
    if ( (*it) == "/Local" )
      displayName = i18n( "prefix for local folders", "Local" );
    else {
      DCOPRef folderRef = kmail.call( "getFolder(QString)", *it );
      folderRef.call( "displayName()" ).get( displayName );
    }
    if ( (*it).contains( '/' ) == 1 ) {
      if ( mFolderMap.find( *it ) == mFolderMap.end() )
        mFolderMap.insert( *it, new QListViewItem( mFolderView,
                                                   displayName ) );
    } else {
      const int pos = (*it).findRev( '/' );
      const QString parentFolder = (*it).left( pos );
      mFolderMap.insert( *it,
                         new QCheckListItem( mFolderMap[ parentFolder ],
                                             displayName,
                                             QCheckListItem::CheckBox ) );
    }
  }
}
Exemplo n.º 2
0
bool K3bExporter::startNewK3bProject( DCOPRef &ref, int openmode )
{
    QCString request;
    //K3bOpenMode mode = openMode();

    switch( openmode ) {
    case AudioCD:
        request = "createAudioCDProject()";
        break;

    case DataCD:
        request = "createDataCDProject()";
        break;

    case Abort:
        return false;
    }

    KMessageBox::sorry(0,request);
    if( !ref.send( request ) ) {
        DCOPErrorMessage();
        return false;
    }

    return true;
}
Exemplo n.º 3
0
void MainWindow::go() {
  Photo  *photo;
  Image   img;
  int     num, diff, offset;
  QDir    dir = QDir::home();
  DCOPRef desktop;

  desktop.setRef( "kdesktop", "KBackgroundIface" );   // turns out DCOP is the easiest way
  dir.cd( "images" );
  if (!dir.exists("flickr"))
    dir.mkdir("flickr");
  dir.cd( "flickr" );

  for (photo = photos.first(); photo; photo = photos.next()) {
    num = photo->desktop; 
    if (num == 0)
      continue;

    qDebug("width: %d; height: %d; ratio: %f", photo->width, photo->height, photo->ratio);

    KURL destUrl( QString("file://%1/%2").arg(dir.absPath()).arg(photo->url.fileName()) );
    qDebug( destUrl.url() );
    qDebug( photo->url.url() );
    if (KIO::NetAccess::file_copy(photo->url, destUrl, -1, false)) {
      img.read(destUrl.path());    
      
      if (photo->ratio < dratio) {
        // height needs to be changed
        diff   = (int)roundf(photo->height - (photo->width / dratio));
        offset = diff / 2;
        img.chop(Geometry(0, offset));
        img.crop(Geometry(photo->width, photo->height - diff));
      }
      else if (photo->ratio > dratio) {
        // width needs to be changed
        diff   = (int)roundf(photo->width - (photo->height * dratio));
        offset = diff / 2;
        img.chop(Geometry(offset, 0));
        img.crop(Geometry(photo->width - diff, photo->height));
      }

      img.scale(Geometry(dwidth, dheight));
      img.write(destUrl.path());
    }
    desktop.call( "setWallpaper", num, destUrl.path(), 1 );
  }
}
Exemplo n.º 4
0
void K3bExporter::exportViaDCOP( const KURL::List &urls, DCOPRef &ref, int openmode )
{
    QValueList<DCOPRef> projectList;
    DCOPReply projectListReply = ref.call("projects()");

    if( !projectListReply.get<QValueList<DCOPRef> >(projectList, "QValueList<DCOPRef>") ) {
        DCOPErrorMessage();
        return;
    }

    if( projectList.count() == 0 && !startNewK3bProject(ref, openmode) )
        return;

    if( !ref.send( "addUrls(KURL::List)", DCOPArg(urls, "KURL::List") ) ) {
        DCOPErrorMessage();
        return;
    }
}
Exemplo n.º 5
0
bool CvsProcessWidget::startJob( const DCOPRef &aJob )
{
    kdDebug(9006) << "CvsProcessWidget::startJob(const DCOPRef &) here!" << endl;

    clear();
    m_part->mainWindow()->raiseView( this );
    m_part->core()->running( m_part, true );

    // create a DCOP stub for the non-concurrent cvs job
    if (m_job)
    {
        delete m_job;
        m_job = 0;
    }
    m_job = new CvsJob_stub( aJob.app(), aJob.obj() );

    // establish connections to the signals of the cvs m_job
    connectDCOPSignal( m_job->app(), m_job->obj(), "jobExited(bool, int)", "slotJobExited(bool, int)", true );
    connectDCOPSignal( m_job->app(), m_job->obj(), "receivedStdout(QString)", "slotReceivedOutput(QString)", true );
    connectDCOPSignal( m_job->app(), m_job->obj(), "receivedStderr(QString)", "slotReceivedErrors(QString)", true );

    // get command line and add it to output buffer
    QString cmdLine = m_job->cvsCommand();
    m_part->mainWindow()->statusBar()->message( cmdLine );

    kdDebug(9006) << "Running: " << cmdLine << endl;

    // disconnect 3rd party slots from our signals
    disconnect( SIGNAL(jobFinished(bool, int)) );

    showInfo( i18n("Started job: %1").arg( cmdLine ) );

#ifdef MYDCOPDEBUG
    g_dcopExitCounter = 0;
    g_dcopOutCounter = 0;
    g_dcopErrCounter = 0;
#endif

    return m_job->execute();
}
Exemplo n.º 6
0
void EditorsDialog::startjob(QString strDir)
{
    kdDebug(9006) << "EditorsDialog::start() workDir = " << strDir << endl;

    DCOPRef job = m_cvsService->editors( strDir );
    m_cvsJob = new CvsJob_stub( job.app(), job.obj() );

    // establish connections to the signals of the cvs m_job
    connectDCOPSignal( job.app(), job.obj(), "jobExited(bool, int)", "slotJobExited(bool, int)", true );
    // We'll read the ouput directly from the job ...
    connectDCOPSignal( job.app(), job.obj(), "receivedStdout(QString)", "slotReceivedOutput(QString)", true );

    kdDebug(9006) << "Running: " << m_cvsJob->cvsCommand() << endl;
    m_cvsJob->execute();
}
Exemplo n.º 7
0
void CVSLogPage::startLog( const QString &workDir, const QString &pathName )
{
    kdDebug(9006) << "CVSLogPage::start() here! workDir = " << workDir <<
        ", pathName = " << pathName << endl;

//    CvsOptions *options = CvsOptions::instance();
    // "cvs log" needs to be done on relative-path basis
    m_pathName = pathName;
	m_diffStrings.clear();

    DCOPRef job = m_cvsService->log( pathName );
    m_cvsLogJob = new CvsJob_stub( job.app(), job.obj() );

    // establish connections to the signals of the cvs m_job
    connectDCOPSignal( job.app(), job.obj(), "jobExited(bool, int)", "slotJobExited(bool, int)", true );
    // We'll read the ouput directly from the job ...
    connectDCOPSignal( job.app(), job.obj(), "receivedStdout(QString)", "slotReceivedOutput(QString)", true );
//    connectDCOPSignal( job.app(), job.obj(), "receivedStderr(QString)", "slotReceivedErrors(QString)", true );

    kdDebug(9006) << "Running: " << m_cvsLogJob->cvsCommand() << endl;
    m_cvsLogJob->execute();
}
Exemplo n.º 8
0
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();
}
Exemplo n.º 9
0
DCOPStub::DCOPStub( const DCOPRef& ref )
    : m_app( ref.app() ), m_obj( ref.obj() ), m_status( CallSucceeded ),d(0)
{
}
Exemplo n.º 10
0
DCOPRef::DCOPRef(const DCOPRef &ref) : d(ref.d)
{
    m_app = ref.app();
    m_obj = ref.obj();
    m_type = ref.type();
}
Exemplo n.º 11
0
void
CollectionScanner::readDir( const QString& dir, QStringList& entries )
{
    static DCOPRef dcopRef( "amarok", "collection" );

    // linux specific, but this fits the 90% rule
    if( dir.startsWith( "/dev" ) || dir.startsWith( "/sys" ) || dir.startsWith( "/proc" ) )
        return;

    const QCString dir8Bit = QFile::encodeName( dir );
    DIR *d = opendir( dir8Bit );
    if( d == NULL ) {
        warning() << "Skipping, " << strerror(errno) << ": " << dir << endl;
        return;
    }
#ifdef USE_SOLARIS
    int dfd = d->d_fd;
#else
    int dfd = dirfd(d);
#endif
    if (dfd == -1) {
	warning() << "Skipping, unable to obtain file descriptor: " << dir << endl;
	closedir(d);
	return;
    }

    struct stat statBuf;
    struct stat statBuf_symlink;
    fstat( dfd, &statBuf );

    struct direntry de;
    memset(&de, 0, sizeof(struct direntry));
    de.dev = statBuf.st_dev;
    de.ino = statBuf.st_ino;

    int f = -1;
#if __GNUC__ < 4
    for( unsigned int i = 0; i < m_processedDirs.size(); ++i )
        if( memcmp( &m_processedDirs[i], &de, sizeof( direntry ) ) == 0 ) {
            f = i; break;
        }
#else
    f = m_processedDirs.find( de );
#endif

    if ( ! S_ISDIR( statBuf.st_mode ) || f != -1 ) {
        debug() << "Skipping, already scanned: " << dir << endl;
        closedir(d);
        return;
    }

    AttributeMap attributes;
    attributes["path"] = dir;
    writeElement( "folder", attributes );

    m_processedDirs.resize( m_processedDirs.size() + 1 );
    m_processedDirs[m_processedDirs.size() - 1] = de;

    for( dirent *ent; ( ent = readdir( d ) ); ) {
        QCString entry (ent->d_name);
        QCString entryname (ent->d_name);

        if ( entry == "." || entry == ".." )
            continue;

        entry.prepend( dir8Bit );

        if ( stat( entry, &statBuf ) != 0 )
            continue;
        if ( lstat( entry, &statBuf_symlink ) != 0 )
            continue;

        // loop protection
        if ( ! ( S_ISDIR( statBuf.st_mode ) || S_ISREG( statBuf.st_mode ) ) )
            continue;

        if ( S_ISDIR( statBuf.st_mode ) && m_recursively && entry.length() && entryname[0] != '.' )
        {
            if ( S_ISLNK( statBuf_symlink.st_mode ) ) {
                char nosymlink[PATH_MAX];
                if ( realpath( entry, nosymlink ) ) {
                    debug() << entry << " is a symlink. Using: " << nosymlink << endl;
                    entry = nosymlink;
                }
            }
            const QString file = QFile::decodeName( entry );

            bool isInCollection = false;
            if( m_incremental )
                dcopRef.call( "isDirInCollection", file ).get( isInCollection );

            if( !m_incremental || !isInCollection )
                // we MUST add a '/' after the dirname
                readDir( file + '/', entries );
        }

        else if( S_ISREG( statBuf.st_mode ) )
            entries.append( QFile::decodeName( entry ) );
    }

    closedir( d );
}
Exemplo n.º 12
0
int run(DCOPRef& ref) {
  DCOPClient *client = KApplication::dcopClient();

  // Disable completion for now.  We might want to add completion of JS
  // keywords and Kst objects at some point.
  rl_bind_key('\t', rl_insert);

  kstName = ref.app();

#ifndef SOLARIS
  signal(SIGALRM, &ping);
  itimerval tv = { { 1, 0 }, { 1, 0 } };
  itimerval old;
  setitimer(ITIMER_REAL, &tv, &old);
#endif

  for (;;) {
    if (!client->registeredApplications().contains(kstName)) {
      printf("%s", _T("Kst application process has terminated.\n"));
      return ERR_KST_TERMINATED;
    }

    char *l = 0L;
    const char *prompt = "kst> ";
    QString line;
    do {
      if (!line.isEmpty()) {
        // replace \ with \n
        line[line.length() - 1] = '\n';
      }

      l = readline(prompt);

      prompt = "";

      if (!l) {
        return 0;
      }
      line += QString(l);
      free(l);
      l = 0L;
    } while (line.endsWith("\\"));

    QString clean = line.stripWhiteSpace();

    if (clean == "exit") {
      return ERR_NONE;
    }

    if (clean == "session") {
      printf("%s\n", ref.app().data());
      continue;
    }

    if (clean == "help") {
      printf("%s", _T("Help:\n"));
      printf("%s", _T("session\t\t\t\tDisplay the name of the session in use\n"));
      printf("%s", _T("help\t\t\t\tDisplay help\n"));
      printf("%s", _T("exit\t\t\t\tExit the command-line interpreter\n"));
      continue;
    }

    if (clean.isEmpty()) {
      continue;
    }

    add_history(line.latin1());

    DCOPReply r = ref.call("evaluate", clean);
    if (r.isValid()) {
      QString res;
      r.get(res);
      if (!res.isEmpty()) {
        printf("%s\n", res.latin1());
      }
    }
  }
}