Commit 651213a4 authored by David Faure's avatar David Faure
Browse files

Ported konqueror's DCOP interfaces to DBus

svn path=/trunk/KDE/kdebase/konqueror/; revision=554173
parent f9b4d732
......@@ -4,7 +4,7 @@ project(konqueror)
set(libkonqueror_intern_KCFG_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/konq_settingsxt.kcfgc)
kde4_add_kcfg_files(libkonqueror_intern_SRCS ${libkonqueror_intern_KCFG_SRCS})
add_subdirectory( client )
#add_subdirectory( client )
add_subdirectory( iconview )
add_subdirectory( listview )
......@@ -14,13 +14,13 @@ endif(UNIX)
add_subdirectory( about )
add_subdirectory( pics )
add_subdirectory( sidebar )
add_subdirectory( preloader )
add_subdirectory( quickprint )
add_subdirectory( remoteencodingplugin )
add_subdirectory( kttsplugin )
#add_subdirectory( sidebar )
#add_subdirectory( preloader )
#add_subdirectory( quickprint )
#add_subdirectory( remoteencodingplugin )
#add_subdirectory( kttsplugin )
add_subdirectory( dirpart )
add_subdirectory( settings )
#add_subdirectory( settings )
include_directories( ${CMAKE_SOURCE_DIR}/libkonq ${CMAKE_SOURCE_DIR}/workspace/kcontrol/input )
add_subdirectory( tests )
......@@ -28,11 +28,6 @@ add_subdirectory( tests )
########### next target ###############
#TODO: port those to DBUS
# KonquerorIface.cc
# KonqMainWindowIface.cc
# KonqViewIface.cc
set(konqueror_KDEINIT_SRCS ${libkonqueror_intern_SRCS}
konq_main.cc
konq_guiclients.cc
......@@ -50,7 +45,11 @@ set(konqueror_KDEINIT_SRCS ${libkonqueror_intern_SRCS}
konq_browseriface.cc
delayedinitializer.cc
konq_mainwindow.cc
konq_extensionmanager.cc )
konq_extensionmanager.cc
KonquerorAdaptor.cpp
KonqMainWindowAdaptor.cpp
KonqViewAdaptor.cpp
)
kde4_automoc(${konqueror_KDEINIT_SRCS})
......@@ -70,7 +69,6 @@ install(TARGETS konqueror DESTINATION bin)
install_files( ${APPLNK_INSTALL_DIR}/.hidden FILES konqfilemgr.desktop )
install_files( ${XDG_APPS_DIR} FILES kfmclient.desktop kfmclient_dir.desktop kfmclient_html.desktop kfmclient_war.desktop konqbrowser.desktop konquerorsu.desktop Home.desktop )
install_files( ${KCFG_INSTALL_DIR} FILES konqueror.kcfg )
install_files( /include FILES KonquerorIface.h )
install_files( ${APPLNK_INSTALL_DIR} FILES konqueror.desktop )
install_files( ${DATA_INSTALL_DIR}/konqueror FILES konqueror.rc konq-simplebrowser.rc )
......@@ -130,13 +128,6 @@ install(FILES profile_simplebrowser.desktop DESTINATION ${CMAKE_INSTALL_PREFIX}$
# konq_extensionmanager.cc
#
#konqueror_la_PCH = AUTO
#
#noinst_HEADERS = KonqMainWindowIface.h KonqViewIface.h delayedinitializer.h \
# konq_actions.h konq_browseriface.h konq_combo.h konq_factory.h \
# konq_frame.h konq_tabs.h konq_guiclients.h konq_main.h konq_mainwindow.h \
# konq_misc.h konq_openurlrequest.h konq_profiledlg.h konq_run.h \
# konq_view.h konq_viewmgr.h konq_extensionmanager.h version.h
#
#konqueror_la_LDFLAGS = -module $(KDE_PLUGIN) $(all_libraries)
#konqueror_la_LIBADD = ../libkonq/libkonq.la libkonqueror_intern.la $(LIBMALLOC) $(LIB_KUTILS)
#
......
/* This file is part of the KDE project
Copyright (C) 2000 Simon Hausmann <hausmann@kde.org>
Copyright (C) 2000 David Faure <faure@kde.org>
Copyright 2000 Simon Hausmann <hausmann@kde.org>
Copyright 2000, 2006 David Faure <faure@kde.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
......@@ -18,54 +18,36 @@
Boston, MA 02110-1301, USA.
*/
#include "KonqMainWindowIface.h"
#include "KonqViewIface.h"
#include "KonqMainWindowAdaptor.h"
#include "KonqViewAdaptor.h"
#include "konq_view.h"
#include <dcopclient.h>
#include <kapplication.h>
#include <kdcopactionproxy.h>
#include <kdcoppropertyproxy.h>
#include <kdebug.h>
#include <kstartupinfo.h>
#include <kwin.h>
KonqMainWindowIface::KonqMainWindowIface( KonqMainWindow * mainWindow )
:
// ARGL I hate this "virtual public DCOPObject" stuff!
DCOPObject( mainWindow->objectName().toUtf8() ),
KMainWindowInterface( mainWindow ), m_pMainWindow( mainWindow )
{
m_dcopActionProxy = new KDCOPActionProxy( mainWindow->actionCollection(), this );
}
KonqMainWindowIface::~KonqMainWindowIface()
{
delete m_dcopActionProxy;
}
void KonqMainWindowIface::openURL( QString url )
KonqMainWindowAdaptor::KonqMainWindowAdaptor( KonqMainWindow * mainWindow )
: QDBusAbstractAdaptor( mainWindow ), m_pMainWindow( mainWindow )
{
m_pMainWindow->openFilteredUrl( url );
// m_dcopActionProxy = new KDCOPActionProxy( mainWindow->actionCollection(), this );
}
void KonqMainWindowIface::newTab( QString url )
KonqMainWindowAdaptor::~KonqMainWindowAdaptor()
{
m_pMainWindow->openFilteredUrl( url, true );
// delete m_dcopActionProxy;
}
void KonqMainWindowIface::openURL( QString url, bool tempFile )
void KonqMainWindowAdaptor::openUrl( const QString& url, bool tempFile )
{
m_pMainWindow->openFilteredUrl( url, false, tempFile );
}
void KonqMainWindowIface::newTab( QString url, bool tempFile )
void KonqMainWindowAdaptor::newTab( const QString& url, bool tempFile )
{
m_pMainWindow->openFilteredUrl( url, true, tempFile );
}
void KonqMainWindowIface::newTabASN( QString url, const DCOPCString& startup_id, bool tempFile )
void KonqMainWindowAdaptor::newTabASN( const QString& url, const QByteArray& startup_id, bool tempFile )
{
#ifdef Q_WS_X11
KStartupInfo::setNewStartupId( m_pMainWindow, startup_id );
......@@ -73,69 +55,31 @@ void KonqMainWindowIface::newTabASN( QString url, const DCOPCString& startup_id,
m_pMainWindow->openFilteredUrl( url, true, tempFile );
}
void KonqMainWindowIface::reload()
void KonqMainWindowAdaptor::reload()
{
m_pMainWindow->slotReload();
}
DCOPRef KonqMainWindowIface::currentView()
QDBusObjectPath KonqMainWindowAdaptor::currentView()
{
DCOPRef res;
kDebug() << k_funcinfo << endl;
KonqView *view = m_pMainWindow->currentView();
if ( !view )
return res;
return QDBusObjectPath();
return DCOPRef( kapp->dcopClient()->appId(), view->dcopObject()->objId() );
return QDBusObjectPath( view->dbusObjectPath() );
}
DCOPRef KonqMainWindowIface::currentPart()
QDBusObjectPath KonqMainWindowAdaptor::currentPart()
{
DCOPRef res;
KonqView *view = m_pMainWindow->currentView();
if ( !view )
return res;
return view->dcopObject()->part();
}
DCOPRef KonqMainWindowIface::action( const DCOPCString &name )
{
return DCOPRef( kapp->dcopClient()->appId(), m_dcopActionProxy->actionObjectId( name ) );
}
return QDBusObjectPath();
DCOPCStringList KonqMainWindowIface::actions()
{
DCOPCStringList res;
QList<KAction *> lst = m_dcopActionProxy->actions();
QList<KAction *>::ConstIterator it = lst.begin();
QList<KAction *>::ConstIterator end = lst.end();
for (; it != end; ++it )
res.append( (*it)->name() );
return res;
return QDBusObjectPath( view->partObjectPath() );
}
QMap<DCOPCString,DCOPRef> KonqMainWindowIface::actionMap()
{
return m_dcopActionProxy->actionMap();
}
DCOPCStringList KonqMainWindowIface::functionsDynamic()
{
return DCOPObject::functionsDynamic() + KDCOPPropertyProxy::functions( m_pMainWindow );
}
bool KonqMainWindowIface::processDynamic( const DCOPCString &fun, const QByteArray &data, DCOPCString &replyType, QByteArray &replyData )
{
if ( KDCOPPropertyProxy::isPropertyRequest( fun, m_pMainWindow ) )
return KDCOPPropertyProxy::processPropertyRequest( fun, data, replyType, replyData, m_pMainWindow );
return DCOPObject::processDynamic( fun, data, replyType, replyData );
}
bool KonqMainWindowIface::windowCanBeUsedForTab()
bool KonqMainWindowAdaptor::windowCanBeUsedForTab()
{
KWin::WindowInfo winfo = KWin::windowInfo( m_pMainWindow->winId(), NET::WMDesktop );
if( !winfo.isOnCurrentDesktop() )
......@@ -145,3 +89,5 @@ bool KonqMainWindowIface::windowCanBeUsedForTab()
return true;
}
#include "KonqMainWindowAdaptor.moc"
/* This file is part of the KDE project
Copyright (C) 2000 Simon Hausmann <hausmann@kde.org>
Copyright (C) 2000 David Faure <faure@kde.org>
Copyright 2000 Simon Hausmann <hausmann@kde.org>
Copyright 2000, 2006 David Faure <faure@kde.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
......@@ -18,69 +18,65 @@
Boston, MA 02110-1301, USA.
*/
#ifndef __KonqMainWindowIface_h__
#define __KonqMainWindowIface_h__
#ifndef __KonqMainWindowAdaptor_h__
#define __KonqMainWindowAdaptor_h__
#include <dcopobject.h>
#include <dcopref.h>
#include <kmainwindowiface.h>
#include <dbus/qdbus.h>
class KonqMainWindow;
class KDCOPActionProxy;
/**
* DCOP interface for a konqueror main window
* DBUS interface for a konqueror main window
*/
class KonqMainWindowIface : public KMainWindowInterface
class KonqMainWindowAdaptor : public QDBusAbstractAdaptor
{
K_DCOP
public:
KonqMainWindowIface( KonqMainWindow * mainWindow );
~KonqMainWindowIface();
k_dcop:
void openURL( QString url );
void newTab( QString url );
void openURL( QString url, bool tempFile );
void newTab( QString url, bool tempFile );
void newTabASN( QString url, const DCOPCString& startup_id, bool tempFile );
/**
* Reloads the current view.
*/
void reload();
/**
* @return reference to the current KonqView
*/
DCOPRef currentView();
/**
* @return reference to the current part
*/
DCOPRef currentPart();
DCOPRef action( const DCOPCString &name );
DCOPCStringList actions();
QMap<DCOPCString,DCOPRef> actionMap();
/**
* Used by kfmclient when searching a window to open a tab within
*/
bool windowCanBeUsedForTab();
Q_OBJECT
Q_CLASSINFO("D-Bus Interface", "org.kde.Konqueror.MainWindow")
public:
virtual DCOPCStringList functionsDynamic();
virtual bool processDynamic( const DCOPCString &fun, const QByteArray &data, DCOPCString &replyType, QByteArray &replyData );
private:
KonqMainWindowAdaptor( KonqMainWindow * mainWindow );
~KonqMainWindowAdaptor();
public slots:
/**
* Open a url in this window
* @param url the url to open
* @param tempFile whether to delete the file after use, usually this is false
*/
void openUrl( const QString& url, bool tempFile );
/**
* Open a url in a new tab in this window
* @param url the url to open
* @param tempFile whether to delete the file after use, usually this is false
*/
void newTab( const QString& url, bool tempFile );
void newTabASN( const QString& url, const QByteArray& startup_id, bool tempFile );
/**
* Reloads the current view.
*/
void reload();
/**
* @return reference to the current KonqView
*/
QDBusObjectPath currentView();
/**
* @return reference to the current part
*/
QDBusObjectPath currentPart();
/**
* Used by kfmclient when searching a window to open a tab within
*/
bool windowCanBeUsedForTab();
KonqMainWindow * m_pMainWindow;
KDCOPActionProxy *m_dcopActionProxy;
private:
KonqMainWindow * m_pMainWindow;
};
#endif
......
/* This file is part of the KDE project
Copyright (C) 2000 Simon Hausmann <hausmann@kde.org>
Copyright (C) 2000 David Faure <faure@kde.org>
Copyright 2000 Simon Hausmann <hausmann@kde.org>
Copyright 2000, 2006 David Faure <faure@kde.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
......@@ -18,118 +18,103 @@
Boston, MA 02110-1301, USA.
*/
#include "KonqViewIface.h"
#include "KonqViewAdaptor.h"
#include "konq_view.h"
#include <kapplication.h>
#include <dcopclient.h>
KonqViewIface::KonqViewIface( KonqView * view )
: DCOPObject( DCOPCString( view->objectName().toUtf8() ) ), m_pView ( view )
KonqViewAdaptor::KonqViewAdaptor( KonqView * view )
: m_pView ( view )
{
}
KonqViewIface::~KonqViewIface()
KonqViewAdaptor::~KonqViewAdaptor()
{
}
void KonqViewIface::openURL( QString url, const QString & locationBarURL, const QString & nameFilter )
void KonqViewAdaptor::openUrl( const QString& url, const QString & locationBarURL, const QString & nameFilter )
{
KUrl u(url);
m_pView->openURL( u, locationBarURL, nameFilter );
m_pView->openURL( KUrl(url), locationBarURL, nameFilter );
}
bool KonqViewIface::changeViewMode( const QString &serviceType,
const QString &serviceName )
bool KonqViewAdaptor::changeViewMode( const QString &serviceType,
const QString &serviceName )
{
return m_pView->changeViewMode( serviceType, serviceName );
return m_pView->changeViewMode( serviceType, serviceName );
}
void KonqViewIface::lockHistory()
void KonqViewAdaptor::lockHistory()
{
m_pView->lockHistory();
m_pView->lockHistory();
}
void KonqViewIface::stop()
void KonqViewAdaptor::stop()
{
m_pView->stop();
m_pView->stop();
}
QString KonqViewIface::url()
QString KonqViewAdaptor::url()
{
return m_pView->url().url();
return m_pView->url().url();
}
QString KonqViewIface::locationBarURL()
QString KonqViewAdaptor::locationBarURL()
{
return m_pView->locationBarURL();
return m_pView->locationBarURL();
}
QString KonqViewIface::serviceType()
QString KonqViewAdaptor::serviceType()
{
return m_pView->serviceType();
return m_pView->serviceType();
}
QStringList KonqViewIface::serviceTypes()
QStringList KonqViewAdaptor::serviceTypes()
{
return m_pView->serviceTypes();
return m_pView->serviceTypes();
}
DCOPRef KonqViewIface::part()
QDBusObjectPath KonqViewAdaptor::part()
{
DCOPRef res;
KParts::ReadOnlyPart *part = m_pView->part();
if ( !part )
return res;
QVariant dcopProperty = part->property( "dcopObjectId" );
if ( dcopProperty.type() != QVariant::CString )
return res;
res.setRef( kapp->dcopClient()->appId(), dcopProperty.toCString() );
return res;
return QDBusObjectPath( m_pView->partObjectPath() );
}
void KonqViewIface::enablePopupMenu( bool b )
void KonqViewAdaptor::enablePopupMenu( bool b )
{
m_pView->enablePopupMenu( b );
m_pView->enablePopupMenu( b );
}
uint KonqViewIface::historyLength()const
uint KonqViewAdaptor::historyLength()const
{
return m_pView->historyLength();
}
bool KonqViewIface::allowHTML() const
bool KonqViewAdaptor::allowHTML() const
{
return m_pView->allowHTML();
}
void KonqViewIface::goForward()
void KonqViewAdaptor::goForward()
{
m_pView->go(-1);
}
void KonqViewIface::goBack()
void KonqViewAdaptor::goBack()
{
m_pView->go(+1);
}
bool KonqViewIface::isPopupMenuEnabled() const
bool KonqViewAdaptor::isPopupMenuEnabled() const
{
return m_pView->isPopupMenuEnabled();
}
bool KonqViewIface::canGoBack()const
bool KonqViewAdaptor::canGoBack()const
{
return m_pView->canGoBack();
}
bool KonqViewIface::canGoForward()const
bool KonqViewAdaptor::canGoForward()const
{
return m_pView->canGoForward();
}
#include "KonqViewAdaptor.moc"
/* This file is part of the KDE project
Copyright (C) 2000 Simon Hausmann <hausmann@kde.org>
Copyright (C) 2000 David Faure <faure@kde.org>
Copyright 2000 Simon Hausmann <hausmann@kde.org>
Copyright 2000, 2006 David Faure <faure@kde.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
......@@ -18,86 +18,87 @@
Boston, MA 02110-1301, USA.
*/
#ifndef __KonqViewIface_h__
#define __KonqViewIface_h__
#ifndef __KonqViewAdaptor_h__
#define __KonqViewAdaptor_h__
#include <dcopobject.h>
#include <QStringList>
#include <dcopref.h>
#include <dbus/qdbus.h>
class KonqView;
/**
* DCOP interface for a konqueror main window
* DBus interface for a konqueror view
*/
class KonqViewIface : virtual public DCOPObject
class KonqViewAdaptor : public QObject
{
K_DCOP
Q_OBJECT
Q_CLASSINFO("D-Bus Interface", "org.kde.Konqueror.View")
public:
KonqViewIface( KonqView * view );
~KonqViewIface();
k_dcop:
/**
* Displays another URL, but without changing the view mode
* (Make sure the part can display this URL)
*/
void openURL( QString url,
const QString & locationBarURL,
const QString & nameFilter );
/**
* Change the type of view (i.e. loads a new konqueror view)
* @param serviceType the service type we want to show
* @param serviceName allows to enforce a particular service to be chosen,
* @see KonqFactory.
*/
bool changeViewMode( const QString &serviceType,
const QString &serviceName );
/**
* Call this to prevent next openURL() call from changing history lists
* Used when the same URL is reloaded (for instance with another view mode)
*/
void lockHistory();
/**
* Stop loading
*/
void stop();
/**
* Retrieve view's URL
*/
QString url();
/**
* Get view's location bar URL, i.e. the one that the view signals
* It can be different from url(), for instance if we display a index.html
*/
QString locationBarURL();
/**
* @return the servicetype this view is currently displaying
*/
QString serviceType();
/**
* @return the servicetypes this view is capable to display
*/
QStringList serviceTypes();
/**
* @return the part embedded into this view
*/
DCOPRef part();