Beispiel #1
0
int KPrinterImpl::dcopPrint(const TQString& cmd, const TQStringList& files, bool removeflag)
{
	kdDebug(500) << "tdeprint: print command: " << cmd << endl;

	int result = 0;
	DCOPClient	*dclient = kapp->dcopClient();
	if (!dclient || (!dclient->isAttached() && !dclient->attach()))
	{
		return result;
	}

	TQByteArray data, replyData;
	TQCString replyType;
	TQDataStream arg( data, IO_WriteOnly );
	arg << cmd;
	arg << files;
	arg << removeflag;
	if (dclient->call( "kded", "tdeprintd", "print(TQString,TQStringList,bool)", data, replyType, replyData ))
	{
		if (replyType == "int")
		{
			TQDataStream _reply_stream( replyData, IO_ReadOnly );
			_reply_stream >> result;
		}
	}
void DictApplet::sendCommand(const QCString &fun, const QString &data)
{
  if (waiting > 0) {
    waiting = 1;
    delayedFunc = fun.copy();
    delayedData = data;
    return;
  }

  DCOPClient *client = kapp->dcopClient();
  if (!client->isApplicationRegistered("kdict")) {
    KApplication::startServiceByDesktopName("kdict");
    waiting = 1;
    delayedFunc = fun.copy();
    delayedData = data;
    QTimer::singleShot(100, this, SLOT(sendDelayedCommand()));
    return;
  } else {
    QCStringList list = client->remoteObjects("kdict");
    if (list.findIndex("KDictIface")==-1) {
      waiting = 1;
      delayedFunc = fun.copy();
      delayedData = data;
      QTimer::singleShot(100, this, SLOT(sendDelayedCommand()));
      return;
    }
  }

  client->send("kdict","default",fun,data);
}
Beispiel #3
0
DCOPReply DCOPRef::callInternal(const QCString &fun, const QCString &args, const QByteArray &data, EventLoopFlag useEventLoop, int timeout)
{
    DCOPReply reply;
    if(isNull())
    {
        qWarning("DCOPRef: call '%s' on null reference error", STR(fun));
        return reply;
    }
    QCString sig = fun;
    if(fun.find('(') == -1)
    {
        sig += args;
        if(args.find("<unknown") != -1)
            qWarning(
                "DCOPRef: unknown type error "
                "<\"%s\",\"%s\">::call(\"%s\",%s",
                STR(m_app), STR(m_obj), STR(fun), args.data() + 1);
    }
    DCOPClient *dc = dcopClient();
    if(!dc || !dc->isAttached())
    {
        qWarning("DCOPRef::call():  no DCOP client or client not attached error");
        return reply;
    }
    dc->call(m_app, m_obj, sig, data, reply.type, reply.data, useEventLoop == UseEventLoop, timeout);
    return reply;
}
Beispiel #4
0
int main(int argc, char **argv)
{
    bool ok;

    KApplication app(argc, argv, "kmobile_client", false);

    // get our DCOP client and attach so that we may use it
    DCOPClient *client = app.dcopClient();
    client->attach();

    QByteArray data;
    QDataStream ds(data, IO_WriteOnly);
//     ds << QString("a");

    QCString replyType;
    QByteArray replyData;
    ok = client->call("kmobile", "kmobileIface", "deviceNames()", data, replyType, replyData);

    QDataStream reply(replyData, IO_ReadOnly); 
    QStringList deviceNames; 
    reply >> deviceNames;

    kdDebug() << QString("%1\n").arg(ok?"Ok":"Failure");
    kdDebug() << QString("Number of currently registered drivers: %1\n").arg(deviceNames.count());
    for (int i=0; i<deviceNames.count(); i++)
      kdDebug() << QString("Device %1: %2\n").arg(i+1).arg(deviceNames[i]);

  //  return app.exec();
}
Beispiel #5
0
bool DCOPRef::sendInternal(const QCString &fun, const QCString &args, const QByteArray &data)
{
    if(isNull())
    {
        qWarning("DCOPRef: send '%s' on null reference error", STR(fun));
        return false;
    }
    Q_UNUSED(data);
    QCString sig = fun;
    if(fun.find('(') == -1)
    {
        sig += args;
        if(args.find("<unknown") != -1)
            qWarning(
                "DCOPRef: unknown type error "
                "<\"%s\",\"%s\">::send(\"%s\",%s",
                STR(m_app), STR(m_obj), STR(fun), args.data() + 1);
    }
    DCOPClient *dc = dcopClient();
    if(!dc || !dc->isAttached())
    {
        qWarning("DCOPRef::send(): no DCOP client or client not attached error");
        return false;
    }
    return dc->send(m_app, m_obj, sig, data);
}
Beispiel #6
0
// the code was taken from pilotDaemon.cc in KPilot
                                                  // static
OSDWidget::KDesktopLockStatus OSDWidget::isKDesktopLockRunning()
{
    if (!Preferences::oSDCheckDesktopLock())
	return NotLocked;

    DCOPClient *dcopptr = KApplication::kApplication()->dcopClient();

    // Can't tell, very weird
    if (!dcopptr || !dcopptr->isAttached())
    {
        kdWarning() << k_funcinfo << ": Could not make DCOP connection." << endl;
        return DCOPError;
    }

    QByteArray data,returnValue;
    QCString returnType;

    if (!dcopptr->call("kdesktop","KScreensaverIface","isBlanked()",
        data,returnType,returnValue,true))
    {
        // KDesktop is not running. Maybe we are in a KDE4 desktop...
        kdDebug() << k_funcinfo << ": Check for screensaver failed." << endl;
        return DCOPError;
    }

    if (returnType == "bool")
    {
        bool b;
        QDataStream reply(returnValue,IO_ReadOnly);
        reply >> b;
        return (b ? Locked : NotLocked);
    }
Beispiel #7
0
void AddAction::updateObjects()
{
	QStringList names;
	theObjects->clear();
	uniqueProgramMap.clear();
	nameProgramMap.clear();

	DCOPClient *theClient = KApplication::kApplication()->dcopClient();
	QCStringList theApps = theClient->registeredApplications();
	for(QCStringList::iterator i = theApps.begin(); i != theApps.end(); ++i)
	{
		if(!QString(*i).find("anonymous")) continue;
		if(!QString(*i).find(i18n( "anonymous" ))) continue;
		QRegExp r("(.*)-[0-9]+");
		QString name = r.exactMatch(QString(*i)) ? r.cap(1) : *i;
		if(names.contains(name)) continue;
		names += name;

		KListViewItem *a = new KListViewItem(theObjects, name);
		uniqueProgramMap[a] = name == QString(*i);
		nameProgramMap[a] = *i;

		QCStringList theObjects = theClient->remoteObjects(*i);
		for(QCStringList::iterator j = theObjects.begin(); j != theObjects.end(); ++j)
			if(*j != "ksycoca" && *j != "qt")// && getFunctions(*i, *j).count())
				new KListViewItem(a, *j);
	}
	updateFunctions();
}
Beispiel #8
0
QuickLauncher::QuickLauncher(const TQString& configFile, Type type, int actions,
                             TQWidget *parent, const char *name) : 
    KPanelApplet(configFile, type, actions, parent, name)
{
    DCOPObject::setObjId("QuickLauncherApplet");
    DEBUGSTR << endl << endl << endl << "------------" << flush;
    DEBUGSTR << "QuickLauncher::QuickLauncher(" << configFile << ",...)" <<
                endl << flush;

    m_settings = new Prefs(sharedConfig());
    m_settings->readConfig();

    m_needsSave = false;
    m_needsRefresh = false;
    m_refreshEnabled = false;

    m_configDialog = 0;
    m_popup = 0;
    m_appletPopup = 0;
    m_removeAppsMenu = 0;

    m_dragAccepted = false;

    m_buttons = new ButtonGroup;
    m_manager = new FlowGridManager;
    m_newButtons = 0;
    m_oldButtons = 0;
    m_dragButtons = 0;

    m_configAction = new TDEAction(i18n("Configure Quicklauncher..."), "configure", TDEShortcut(),
        TQT_TQOBJECT(this), TQT_SLOT(slotConfigure()), TQT_TQOBJECT(this));

    m_saveTimer = new TQTimer(this, "m_saveTimer");
    connect(m_saveTimer, TQT_SIGNAL(timeout()), this, TQT_SLOT(saveConfig()));

    m_popularity = new PopularityStatistics();

    setBackgroundOrigin(AncestorOrigin);

    loadConfig();

    buildPopupMenu();
    m_minPanelDim = std::max(16, m_settings->iconDimChoices()[1]);
    refreshContents();
    setRefreshEnabled(true);

    setAcceptDrops(true);
    //TQToolTip::add(this, i18n("Drop applications here"));
    DEBUGSTR << "    QuickLauncher::QuickLauncher(" << configFile << 
                ",...) END" << endl << flush;

    DCOPClient *dcopClient = TDEApplication::dcopClient();
    dcopClient->connectDCOPSignal(0, "appLauncher", 
        "serviceStartedByStorageId(TQString,TQString)",
        "QuickLauncherApplet",
        "serviceStartedByStorageId(TQString,TQString)",
        false);
    kdDebug() << "Quicklauncher registered DCOP signal" << endl;
}
Beispiel #9
0
void ping(int) {
  DCOPClient *client = KApplication::dcopClient();
  if (!client->registeredApplications().contains(kstName)) {
    printf("%s", _T("Kst application process has terminated.\n"));
    rl_cleanup_after_signal();
    exit(ERR_KST_TERMINATED);
  }
}
Beispiel #10
0
Wallpaper::Wallpaper( QWidget *parent, const char* name )
    : WallpaperDlg( parent, name )
{
    changePaper = true;
    selectedPaper = "";

    QStringList lst = KGlobal::dirs()->findAllResources("wallpaper", "*.desktop", false /* no recursion */, true /* unique files */ );
    QString line,lname,lang,langCode;

    // FIXME: What about other languages?
    lang = QString(getenv("LC_ALL"));
    if (lang == "tr_TR.UTF-8")
        langCode="Name[tr]";
    else
        langCode="Name";

    for(QStringList::Iterator it = lst.begin(); it != lst.end(); ++it)
    {
        if(!(*it).endsWith(".svgz.desktop"))
        {
                QFile desktopFile(*it);
                QTextStream stream(&desktopFile);
                desktopFile.open(IO_ReadOnly);

                bool foundName = false;
                while(!foundName && (line = stream.readLine()))
                {
                    if (line.startsWith(langCode))
                    {
                        lname = line.section("=",1,1);
                        foundName=true;
                    }
                }
            papers.insert(lname, (*it).remove(".desktop"));
            desktopFile.close();
        }
    }

    QMap<QString, QString>::ConstIterator it = papers.begin();
    for(; it != papers.constEnd(); ++it)
        wallpaperBox->insertItem(it.key());

    connect(testButton, SIGNAL(clicked()), this , SLOT(testWallpaper()));
    connect(wallpaperBox, SIGNAL(activated(int)), this, SLOT(paperSelected(int)));
    connect(changeCheck, SIGNAL(toggled(bool)), this, SLOT(optionChanged(bool)));

    emit paperSelected(0);

    // Backup old walpaper name
    DCOPClient *client = kapp->dcopClient();
    QByteArray replyData;
    QCString replyType;

    client->call("kdesktop", "KBackgroundIface", "currentWallpaper(int)", 6, replyType, replyData);
    QDataStream reply(replyData, IO_ReadOnly);
    reply >> oldWallpaper;
}
Beispiel #11
0
void Style::testStyle()
{
    // Read entire XML into DOM Tree
    QFile file(selectedStyle);
    file.open(IO_ReadOnly);
    dom.setContent(file.readAll());
    file.close();

    // attach to dcop
    DCOPClient *client = kapp->dcopClient();
    if (!client->isAttached())
        client->attach();

    // kicker settings
    KConfig *kickerConf = new KConfig("kickerrc");
    kickerConf->setGroup("General");

    QDomElement Kicker = dom.elementsByTagName("kicker").item(0).toElement();

    kickerConf->writeEntry("LegacyKMenu", !checkKickoff->isChecked());
    kickerConf->writeEntry("Transparent", getProperty(Kicker, "Transparent", "value"));
    kickerConf->writeEntry("SizePercentage", getProperty(Kicker, "SizePercentage", "value"));
    kickerConf->writeEntry("CustomSize", getProperty(Kicker, "CustomSize", "value"));
    kickerConf->writeEntry("Position", getProperty(Kicker, "Position", "value"));
    kickerConf->writeEntry("Alignment", getProperty(Kicker, "Alignment", "value"));
    kickerConf->sync();
    delete kickerConf;

    // restart kicker
    client->send("kicker", "kicker", "restart()", "");

    // kwin settings
    KConfig *kwinConf = new KConfig("kwinrc");
    kwinConf->setGroup("Style");

    QDomElement KWin = dom.elementsByTagName("kwin").item(0).toElement();

    kwinConf->writeEntry("PluginLib", getProperty(KWin, "PluginLib", "value"));
    kwinConf->sync();
    delete kwinConf;

    // restart kwin
    client->send("kwin", "KWinInterface", "reconfigure()", "");

    // widget settings
    KConfig *globalConf = new KConfig("kdeglobals");
    globalConf->setGroup("General");

    QDomElement Widget = dom.elementsByTagName("widget").item(0).toElement();

    globalConf->writeEntry("widgetStyle", getProperty(Widget, "widgetStyle", "value"));
    globalConf->sync();
    delete globalConf;

    KIPC::sendMessageAll(KIPC::StyleChanged);
}
Beispiel #12
0
Slave* Slave::holdSlave( const QString &protocol, const KURL& url )
{
    //kdDebug(7002) << "holdSlave '" << protocol << "' for " << url.prettyURL() << endl;
    // Firstly take into account all special slaves
    if (protocol == "data")
        return 0;

    DCOPClient *client = kapp->dcopClient();
    if (!client->isAttached())
	client->attach();

    QString prefix = locateLocal("socket", KGlobal::instance()->instanceName());
    KTempFile socketfile(prefix, QString::fromLatin1(".slave-socket"));
    if ( socketfile.status() != 0 )
	return 0;

#ifdef __CYGWIN__
   socketfile.close();
   socketfile.unlink();
#endif

#ifndef Q_WS_WIN
    KServerSocket *kss = new KServerSocket(QFile::encodeName(socketfile.name()));

    Slave *slave = new Slave(kss, protocol, socketfile.name());
#else
    Slave *slave = 0;
#endif

    QByteArray params, reply;
    QCString replyType;
    QDataStream stream(params, IO_WriteOnly);
    stream << url << socketfile.name();

    QCString launcher = KApplication::launcher();
    if (!client->call(launcher, launcher, "requestHoldSlave(KURL,QString)",
        params, replyType, reply)) {
        delete slave;
        return 0;
    }
    QDataStream stream2(reply, IO_ReadOnly);
    pid_t pid;
    stream2 >> pid;
    if (!pid)
    {
        delete slave;
        return 0;
    }
#ifndef Q_WS_WIN
    slave->setPID(pid);
    QTimer::singleShot(1000*SLAVE_CONNECTION_TIMEOUT_MIN, slave, SLOT(timeout()));
#endif
    return slave;
}
Beispiel #13
0
KDE_EXPORT void
wake_laptop_daemon()
{
	DCOPClient      *dclient = kapp->dcopClient();
        if (!dclient || (!dclient->isAttached() && !dclient->attach())) 
		return;

	TQByteArray data;
	TQDataStream arg( data, IO_WriteOnly );
	(void) dclient->send( "kded", "klaptopdaemon", "restart()", data );
}
Beispiel #14
0
void EditAction::updateDCOPObjects()
{
	theDCOPObjects->clear();
	DCOPClient *theClient = TDEApplication::kApplication()->dcopClient();
	if(theDCOPApplications->currentText().isNull() || theDCOPApplications->currentText().isEmpty()) return;
	QCStringList theObjects = theClient->remoteObjects(nameProgramMap[theDCOPApplications->currentText()].utf8());
	if(!theObjects.size() && theDCOPApplications->currentText() == (*theAction).program()) theDCOPObjects->insertItem((*theAction).object());
	for(QCStringList::iterator j = theObjects.begin(); j != theObjects.end(); ++j)
		if(*j != "tdesycoca" && *j != "qt" && AddAction::getFunctions(nameProgramMap[theDCOPApplications->currentText()], *j).count())
			theDCOPObjects->insertItem(TQString::fromUtf8(*j));
	updateDCOPFunctions();
}
Beispiel #15
0
static ParseNode f_dcop(Parser*, const ParameterList& params)
{
  QCString appId = params[0].toString().latin1();
  QCString object = params[1].toString().latin1();
  QString function = params[2].toString().section('(', 0, 0);
  QStringList items = QStringList::split(",", params[2].toString().section('(', 1, 1).section(')', 0, 0));
  QByteArray byteData;
  QDataStream byteDataStream(byteData, IO_WriteOnly);

  if (items.count() != params.count() - 3)
  {
     qDebug("Wrong number of parameters");
     return ParseNode();
  }
  int i = 3;
  for (QStringList::Iterator it = items.begin(); it != items.end(); ++it)
  {
    *it = (*it).stripWhiteSpace();
    if (*it == "int")
      byteDataStream << params[i++].toInt();
    else if (*it == "long")
      byteDataStream << params[i++].toInt();
    else if (*it == "float")
      byteDataStream << params[i++].toDouble();
    else if (*it == "double")
      byteDataStream << params[i++].toDouble();
    else if (*it == "bool")
      byteDataStream << (bool)params[i++].toInt();
    else if (*it == "QStringList")
      if (params[i].toString().find('\n') != -1)
        byteDataStream << QStringList::split("\n", params[i++].toString(), true);
      else
        byteDataStream << QStringList::split("\\n", params[i++].toString(), true);
    else 
      byteDataStream << params[i++].toString();
  }
  function.append(QString("(%1)").arg(items.join(",")));
  QCString replyType, byteReply;
  DCOPClient* cl = KApplication::dcopClient();
  if (!cl || !cl->call(appId, object, function.latin1(),
       byteData, replyType, byteReply))
  {
    qDebug("DCOP failure");
    return ParseNode();
  }
  QDataStream byteReplyStream(byteReply, IO_ReadOnly);
  if (replyType == "QString")
  {
    QString text;
    byteReplyStream >> text;
    return text;
  }
Beispiel #16
0
const QStringList AddAction::getFunctions(const QString app, const QString obj)
{
	QStringList ret;
	DCOPClient *theClient = KApplication::kApplication()->dcopClient();
	QCStringList theApps = theClient->remoteFunctions(app.utf8(), obj.utf8());
	for(QCStringList::iterator i = theApps.begin(); i != theApps.end(); ++i)
		if(	*i != "QCStringList interfaces()" &&
			*i != "QCStringList functions()" &&
			*i != "QCStringList objects()" &&
			*i != "QCStringList find(QCString)" )
			ret += QString::fromUtf8(*i);
	return ret;
}
Beispiel #17
0
void Desktop::loadBgPixmap(void)
{
//  if (!m_bgDirty) return;
  DCOPClient *client = kapp->dcopClient();
  if (!client->isAttached())
      client->attach();
  QByteArray data, data2, replyData;
  QCString replyType;
  if (client->call("kdesktop", "KBackgroundIface", "isCommon()",
                  data, replyType, replyData))
  {
    QDataStream reply(replyData, IO_ReadOnly);
    if (replyType == "bool") {
      reply >> m_isCommon;
    }
Beispiel #18
0
void AddresseeWidget::saveSettings()
{
  KConfig config( "kabcrc" );
  config.setGroup( "General" );

  config.writeEntry( "Prefixes", mPrefix->nameParts() );
  config.writeEntry( "Inclusions", mInclusion->nameParts() );
  config.writeEntry( "Suffixes", mSuffix->nameParts() );

  KConfig cfg( "kaddressbookrc" );
  cfg.setGroup( "General" );
  cfg.writeEntry( "FormattedNameType", mFormattedNameCombo->currentItem() );

  DCOPClient *client = DCOPClient::mainClient();
  if ( client )
      client->emitDCOPSignal( "KABC::AddressBookConfig", "changed()", QByteArray() );
}
Beispiel #19
0
int main( int argc, char** argv )
{
    if (( argc < 2) || (argv[1][0] == '-' )) {
        fprintf( stderr, "Usage: dcopstart <application> [url1] [url2] ...\n" );
        exit(0);
    }

    DCOPClient client;
    client.attach();
    dcop = &client;

    QCString app;
    QCString objid;
    QCString function;
    /*char **args = 0;*/
    startApp( argv[1], argc - 2, (const char**)&argv[2] );

    return 0;
}
Beispiel #20
0
int main(int argc, char **argv)
{
    KApplication app(argc, argv, "kerp_client", false);

    // get our DCOP client and attach so that we may use it
    DCOPClient *client = app.dcopClient();
    client->attach();

    // do a 'send' for now
    QByteArray data;
    QDataStream ds(data, IO_WriteOnly);
    if (argc > 1)
        ds << QString(argv[1]);
    else
        ds << QString("http://www.kde.org");
    client->send("kerp", "kerpIface", "openURL(QString)", data);

    return app.exec();
}
Beispiel #21
0
void KRootPixmap::enableExports()
{
#ifdef Q_WS_X11
    kdDebug(270) << k_lineinfo << "activating background exports.\n";
    DCOPClient *client = kapp->dcopClient();
    if(!client->isAttached())
        client->attach();
    QByteArray data;
    QDataStream args(data, IO_WriteOnly);
    args << 1;

    QCString appname("kdesktop");
    int screen_number = DefaultScreen(qt_xdisplay());
    if(screen_number)
        appname.sprintf("kdesktop-screen-%d", screen_number);

    client->send(appname, "KBackgroundIface", "setExport(int)", data);
#endif
}
Beispiel #22
0
void KcmKRfb::checkKInetd(bool &kinetdAvailable, bool &krfbAvailable) {
    kinetdAvailable = false;
    krfbAvailable = false;

    DCOPClient *d = KApplication::dcopClient();

    QByteArray sdata, rdata;
    QCString replyType;
    QDataStream arg(sdata, IO_WriteOnly);
    arg << QString("krfb");
    if (!d->call ("kded", "kinetd", "isInstalled(QString)", sdata, replyType, rdata))
        return;

    if (replyType != "bool")
        return;

    QDataStream answer(rdata, IO_ReadOnly);
    answer >> krfbAvailable;
    kinetdAvailable = true;
}
Beispiel #23
0
void K3bExporter::exportTracks( const KURL::List &urls, int openmode )
{
    if( urls.empty() )
        return;

    DCOPClient *client = DCOPClient::mainClient();
    QCString appId, appObj;
    QByteArray data;

    if( openmode == -1 )
        //ask to open a data or an audio cd project
        openmode = openMode();

    if( !client->findObject( "k3b-*", "K3bInterface", "", data, appId, appObj) )
        exportViaCmdLine( urls, openmode );
    else {
        DCOPRef ref( appId, appObj );
        exportViaDCOP( urls, ref, openmode );
    }
}
Beispiel #24
0
    void RunnerGUI::doubleClickedOnDetails(int para, int /*pos*/)
    {
        static QRegExp reFileAndLine("^(.*)\\[([0-9]+)\\]:");

        QString line = m_testerWidget->details()->text(para);
        m_testerWidget->details()->setSelection(para, 0, para, line.length()-1);

        if ( reFileAndLine.search(line) != -1 )
        {
            DCOPClient client;
            client.attach();
            QByteArray data;
            QDataStream arg(&data, QIODevice::WriteOnly);
            bool ok;
            arg << QString(reFileAndLine.cap(1)) << (reFileAndLine.cap(2).toInt(&ok) - 1);
            client.send("kdevelop-*", "KDevPartController", "editDocument(QString,int)", data);
            client.send("kdevelop-*", "MainWindow", "raise()", "");

            client.detach();
        }
    }
Beispiel #25
0
PanelKMenu::PanelKMenu()
  : PanelServiceMenu(QString::null, QString::null, 0, "KMenu")
  , bookmarkMenu(0)
  , bookmarkOwner(0)
{
    static const QCString dcopObjId("KMenu");
    DCOPObject::setObjId(dcopObjId);
    // set the first client id to some arbitrarily large value.
    client_id = 10000;
    // Don't automatically clear the main menu.
    disableAutoClear();
    actionCollection = new KActionCollection(this);
    setCaption(i18n("K Menu"));
    connect(Kicker::the(), SIGNAL(configurationChanged()),
            this, SLOT(configChanged()));
    DCOPClient *dcopClient = KApplication::dcopClient();
    dcopClient->connectDCOPSignal(0, "appLauncher",
        "serviceStartedByStorageId(QString,QString)",
        dcopObjId,
        "slotServiceStartedByStorageId(QString,QString)",
        false);
}
Beispiel #26
0
int main(int argc, char *argv[])
{
	KAboutData aboutData( "kmousetool", I18N_NOOP("KMouseTool"),
	KMOUSETOOL_VERSION, description, KAboutData::License_GPL,
	"(c) 2002-2003, Jeff Roush\n(c) 2003, Gunnar Schmi Dt", 0, "http://www.mousetool.com", "*****@*****.**");

	aboutData.addAuthor("Gunnar Schmi Dt", I18N_NOOP("Current maintainer"), "*****@*****.**", "http://www.schmi-dt.de");
	aboutData.addAuthor("Olaf Schmidt", I18N_NOOP("Usability improvements"), "*****@*****.**");
	aboutData.addAuthor("Jeff Roush", I18N_NOOP("Original author"), "*****@*****.**", "http://www.mousetool.com");

	aboutData.addCredit("Joe Betts");
	KCmdLineArgs::init( argc, argv, &aboutData );
	KCmdLineArgs::addCmdLineOptions( options ); // Add our own options.
	KUniqueApplication::addCmdLineOptions();

	if (!KUniqueApplication::start()) {
		DCOPClient *client = new DCOPClient();
		client->attach();
		QByteArray  data;
		QCString    replyType;
		QByteArray  replyData;
		if ( !client->call("kmousetool", "qt/KMouseToolUI", "show()",
					data, replyType, replyData, true) ||
			!client->call("kmousetool", "qt/KMouseToolUI", "raise()",
					data, replyType, replyData, true) )
		fprintf(stderr, "The DCOP calls failed\n");
		delete client;
		exit(0);
	}
	KUniqueApplication a;

	KMouseTool *kmousetool = new KMouseTool();

	if (!kapp->config()->readBoolEntry("IsMinimized", false))
		kmousetool->show();

	return a.exec();
}
Beispiel #27
0
void EditAction::updateDCOPApplications()
{
	TQStringList names;

	theDCOPApplications->clear();
	DCOPClient *theClient = TDEApplication::kApplication()->dcopClient();
	QCStringList theApps = theClient->registeredApplications();
	for(QCStringList::iterator i = theApps.begin(); i != theApps.end(); ++i)
	{
		if(!TQString(*i).find("anonymous")) continue;
		TQRegExp r("(.*)-[0-9]+");
		TQString name = r.exactMatch(TQString(*i)) ? r.cap(1) : *i;
		if(names.contains(name)) continue;
		names += name;

		theDCOPApplications->insertItem(name);
		uniqueProgramMap[name] = name == TQString(*i);
		nameProgramMap[name] = *i;


	}
	updateDCOPObjects();
}
Beispiel #28
0
void Slave::hold(const KURL &url)
{
    if(d->derived)
    { // TODO: clean up before KDE 4
        HoldParams params;
        params.url = &url;
        virtual_hook(VIRTUAL_HOLD, &params);
        return;
    } /*end if*/

    ref();
    {
        QByteArray data;
        QDataStream stream(data, IO_WriteOnly);
        stream << url;
        slaveconn.send(CMD_SLAVE_HOLD, data);
        slaveconn.close();
        dead = true;
        emit slaveDied(this);
    }
    deref();
    // Call KLauncher::waitForSlave(pid);
    {
        DCOPClient *client = kapp->dcopClient();
        if(!client->isAttached())
            client->attach();

        QByteArray params, reply;
        QCString replyType;
        QDataStream stream(params, IO_WriteOnly);
        pid_t pid = m_pid;
        stream << pid;

        QCString launcher = KApplication::launcher();
        client->call(launcher, launcher, "waitForSlave(pid_t)", params, replyType, reply);
    }
}
void DictApplet::sendDelayedCommand()
{
  if (waiting > 100) {   // timeout after ten seconds
    waiting = 0;
    return;
  }

  DCOPClient *client = kapp->dcopClient();
  if (!client->isApplicationRegistered("kdict")) {
    waiting++;
    QTimer::singleShot(100, this, SLOT(sendDelayedCommand()));
    return;
  } else {
    QCStringList list = client->remoteObjects("kdict");
    if (list.findIndex("KDictIface")==-1) {
      waiting++;
      QTimer::singleShot(100, this, SLOT(sendDelayedCommand()));
      return;
    }
  }

  client->send("kdict","default",delayedFunc,delayedData);
  waiting = 0;
}
Beispiel #30
0
void KHTMLPluginKTTSD::slotReadOut()
{
    // The parent is assumed to be a KHTMLPart
    if(!parent()->inherits("KHTMLPart"))
        QMessageBox::warning(0, i18n("Cannot Read source"), i18n("You cannot read anything except web pages with\n"
                                                                 "this plugin, sorry."));
    else
    {
        // If KTTSD not running, start it.
        DCOPClient *client = kapp->dcopClient();
        if(!client->isApplicationRegistered("kttsd"))
        {
            QString error;
            if(kapp->startServiceByDesktopName("kttsd", QStringList(), &error))
                QMessageBox::warning(0, i18n("Starting KTTSD Failed"), error);
        }

        // Find out if KTTSD supports xhtml (rich speak).
        QByteArray data;
        QBuffer dataBuf(data);
        QDataStream arg;
        dataBuf.open(IO_WriteOnly);
        arg.setDevice(&dataBuf);
        arg << "" << KSpeech::mtHtml;
        QCString replyType;
        QByteArray replyData;
        bool supportsXhtml = false;
        if(!client->call("kttsd", "KSpeech", "supportsMarkup(QString,uint)", data, replyType, replyData, true))
            QMessageBox::warning(0, i18n("DCOP Call Failed"), i18n("The DCOP call supportsMarkup failed."));
        else
        {
            QDataStream reply(replyData, IO_ReadOnly);
            reply >> supportsXhtml;
        }

        KHTMLPart *part = (KHTMLPart *)parent();

        QString query;
        if(supportsXhtml)
        {
            kdDebug() << "KTTS claims to support rich speak (XHTML to SSML)." << endl;
            if(part->hasSelection())
                query = part->selectedTextAsHTML();
            else
            {
                // TODO: Fooling around with the selection probably has unwanted
                // side effects, but until a method is supplied to get valid xhtml
                // from entire document..
                // query = part->document().toString().string();
                part->selectAll();
                query = part->selectedTextAsHTML();
                // Restore no selection.
                part->setSelection(part->document().createRange());
            }
        }
        else
        {
            if(part->hasSelection())
                query = part->selectedText();
            else
                query = part->htmlDocument().body().innerText().string();
        }
        // kdDebug() << "KHTMLPluginKTTSD::slotReadOut: query = " << query << endl;

        dataBuf.at(0); // reset data
        arg << query << "";
        if(!client->call("kttsd", "KSpeech", "setText(QString,QString)", data, replyType, replyData, true))
            QMessageBox::warning(0, i18n("DCOP Call Failed"), i18n("The DCOP call setText failed."));
        dataBuf.at(0);
        arg << 0;
        if(!client->call("kttsd", "KSpeech", "startText(uint)", data, replyType, replyData, true))
            QMessageBox::warning(0, i18n("DCOP Call Failed"), i18n("The DCOP call startText failed."));
    }
}