Browse Source

* Large set of SuSE patches to fix bugs and add functionality

* kdemm is included but not used by knotify as it does not work out of the box


git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdelibs@1171141 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
tags/v3.5.13
tpearson 9 years ago
parent
commit
96900dbce3
100 changed files with 4259 additions and 179 deletions
  1. 1
    1
      Makefile.am.in
  2. 39
    0
      catalog.xml
  3. 5
    0
      dcop/KDE-ICE/Xtranssock.c
  4. 3
    1
      dcop/dcopc.c
  5. 3
    1
      dcop/dcopclient.cpp
  6. 3
    1
      dcop/dcopserver_shutdown.c
  7. 1
    1
      interfaces/kimproxy/library/kimproxy.cpp
  8. 2
    2
      interfaces/kmediaplayer/kfileaudiopreview/kfileaudiopreview.cpp
  9. 3
    3
      kate/part/katehighlight.cpp
  10. 1
    1
      kdecore/eventsrc
  11. 2
    0
      kdecore/fakes.c
  12. 17
    3
      kdecore/kapplication.cpp
  13. 5
    1
      kdecore/kcatalogue.cpp
  14. 18
    0
      kdecore/kconfigbase.cpp
  15. 1
    0
      kdecore/kconfigbase.h
  16. 3
    1
      kdecore/kcrash.cpp
  17. 26
    5
      kdecore/kdesktopfile.cpp
  18. 2
    0
      kdecore/kdesktopfile.h
  19. 8
    1
      kdecore/klocale.cpp
  20. 13
    4
      kdecore/kstandarddirs.cpp
  21. 3
    1
      kdecore/kwinmodule.cpp
  22. 5
    1
      kded/Makefile.am
  23. 18
    10
      kded/khostname.cpp
  24. 54
    0
      kded/kmimelist.cpp
  25. 58
    17
      kdefx/kstyle.cpp
  26. BIN
      kdemm/0.png
  27. 31
    0
      kdemm/DESIGN
  28. 43
    0
      kdemm/Makefile.am
  29. 27
    0
      kdemm/TODO
  30. 78
    0
      kdemm/backend.cpp
  31. 86
    0
      kdemm/backend.h
  32. 69
    0
      kdemm/channel.cpp
  33. 96
    0
      kdemm/channel.h
  34. 296
    0
      kdemm/factory.cpp
  35. 222
    0
      kdemm/factory.h
  36. 41
    0
      kdemm/mixeriface.h
  37. 30
    0
      kdemm/mmbackendinfo.desktop
  38. 53
    0
      kdemm/player.cpp
  39. 259
    0
      kdemm/player.h
  40. 533
    0
      kdemm/reqspec.html
  41. 198
    0
      kdemm/simpleplayer.cpp
  42. 72
    0
      kdemm/simpleplayer.h
  43. 30
    0
      kdemm/test/Makefile.am
  44. 38
    0
      kdemm/test/main.cpp
  45. 299
    0
      kdemm/test/statetest.cpp
  46. 57
    0
      kdemm/test/statetest.h
  47. 194
    0
      kdemm/test/testwidget.cpp
  48. 64
    0
      kdemm/test/testwidget.h
  49. 34
    0
      kdemm/videoplayer.cpp
  50. 54
    0
      kdemm/videoplayer.h
  51. 31
    0
      kdemm/volumecontrold/Makefile.am
  52. 47
    0
      kdemm/volumecontrold/volumecontrold.cpp
  53. 13
    0
      kdemm/volumecontrold/volumecontrold.desktop
  54. 53
    0
      kdemm/volumecontrold/volumecontrold.h
  55. 1
    0
      kdeprint/cups/cupsdconf2/cupsddialog.cpp
  56. 1
    1
      kdeprint/cups/kmcupsmanager.cpp
  57. 8
    2
      kdeprint/kmvirtualmanager.cpp
  58. 3
    0
      kdeprint/kprintpreview.cpp
  59. 18
    8
      kdeprint/management/smbview.cpp
  60. 2
    1
      kdesu/defaults.h
  61. 1
    1
      kdeui/Makefile.am
  62. 11
    0
      kdeui/kaction.cpp
  63. 22
    1
      kdeui/kactionclasses.cpp
  64. 113
    2
      kdeui/kcombobox.cpp
  65. 46
    0
      kdeui/kcombobox.h
  66. 29
    0
      kdeui/kfontcombo.cpp
  67. 112
    9
      kdeui/kjanuswidget.cpp
  68. 9
    0
      kdeui/kjanuswidget.h
  69. 4
    1
      kdeui/kpassdlg.cpp
  70. 1
    1
      kdeui/ksconfig.cpp
  71. 1
    1
      kdeui/ksyntaxhighlighter.cpp
  72. 27
    4
      kdeui/ktip.cpp
  73. 21
    3
      kdeui/qxembed.cpp
  74. 5
    0
      kdeui/qxembed.h
  75. 1
    1
      kdoctools/kio_help.cpp
  76. 11
    11
      khtml/ecma/xmlhttprequest.cpp
  77. 159
    5
      khtml/khtmlview.cpp
  78. 20
    0
      khtml/khtmlview.h
  79. 17
    1
      khtml/rendering/render_form.cpp
  80. 3
    1
      khtml/rendering/render_form.h
  81. 14
    1
      kinit/autostart.cpp
  82. 19
    6
      kinit/lnusertemp.c
  83. 3
    1
      kinit/wrapper.c
  84. 6
    0
      kio/kfile/kfiledialog.cpp
  85. 49
    10
      kio/kfile/kfilesharedlg.cpp
  86. 3
    0
      kio/kfile/kfilesharedlg.h
  87. 12
    1
      kio/kfile/kurlbar.cpp
  88. 2
    1
      kio/kio/kdirwatch.cpp
  89. 63
    11
      kio/kio/kfileshare.cpp
  90. 21
    3
      kio/kio/kfileshare.h
  91. 4
    6
      kio/kio/kmimetype.cpp
  92. 4
    2
      kio/kio/kremoteencoding.cpp
  93. 9
    6
      kio/kio/kservice.cpp
  94. 4
    6
      kio/kio/kservicegroup.cpp
  95. 1
    1
      kio/kio/netaccess.cpp
  96. 19
    3
      kio/kssl/kopenssl.cc
  97. 14
    2
      kio/kssl/kopenssl.h
  98. 1
    1
      kio/kssl/ksmimecrypto.cc
  99. 23
    9
      kio/kssl/ksslcertificate.cc
  100. 0
    0
      kio/misc/kwalletd/kwalletd.cpp

+ 1
- 1
Makefile.am.in View File

@@ -18,7 +18,7 @@
# Boston, MA 02110-1301, USA.


COMPILE_FIRST = dcop libltdl kdefx kdecore kunittest kdeui kdesu kjs kwallet kio kded kded_post
COMPILE_FIRST = dcop libltdl kdefx kdecore kunittest kdeui kdesu kjs kwallet kio kded kded_post kdemm
COMPILE_BEFORE_doc = kdoctools
COMPILE_AFTER_kparts = kspell2 kmdi kdeprint kinit kate interfaces kcert khtml krandr
COMPILE_AFTER_kdeprint = kate khtml

+ 39
- 0
catalog.xml View File

@@ -0,0 +1,39 @@
<?xml version="1.0"?>
<!DOCTYPE catalog PUBLIC "-//OASIS//DTD Entity Resolution XML Catalog V1.0//EN"
"http://www.oasis-open.org/committees/entity/release/1.0/catalog.dtd">
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog"
prefer="public">
<public publicId="-//KDE//DTD DocBook XML V4.2-Based Variant V1.1//EN"
uri="dtd/kdex.dtd" />
<public publicId="-//KDE//ELEMENTS DocBook XML Hierarchy Redeclarations 2 V1.0//EN"
uri="dtd/rdbhier2.elements" />
<public publicId="-//KDE//ELEMENTS DocBook XML Pool Redeclarations V1.1//EN"
uri="dtd/rdbpool.elements" />
<public publicId="-//KDE//ELEMENTS DocBook XML Modifications (Restrictions) V1.1//EN"
uri="dtd/modifications.elements" />

<public publicId="-//KDE//ENTITIES DocBook XML General Entity Declarations V1.2//EN"
uri="entities/general.entities" />
<public publicId="-//KDE//ENTITIES DocBook XML General Entity Declarations (Persons) V1.0//EN"
uri="entities/contributor.entities" />

<public publicId="-//KDE//ENTITIES DocBook XML Localisation Entity Declarations V1.0//EN"
uri="entities/l10n.entities" />

<public publicId="-//KDE//DTD DocBook XML V4.1.2-Based Variant V1.1//EN"
uri="obsolete/kdex.dtd" />
<public publicId="-//KDE//ENTITIES DocBook XML General Entity Declarations V1.1//EN"
uri="obsolete/general.entities" />
<public publicId="-//KDE//ELEMENTS DocBook XML Pool Redeclarations V1.0//EN"
uri="obsolete/rdbpool.elements" />
<public publicId="-//KDE//ELEMENTS DocBook XML Modifications V1.0//EN"
uri="obsolete/modifications.elements" />


<public publicId="-//KDE//DTD DocBook XML V4.1.2-Based Variant V1.0//EN"
uri="obsolete/kdex-412-10.dtd" />


<public publicId="-//KDE//DTD DocBook XML V4.1-Based Variant V1.0//EN"
uri="obsolete/kdex-412-10.dtd" />
</catalog>

+ 5
- 0
dcop/KDE-ICE/Xtranssock.c View File

@@ -1444,6 +1444,7 @@ UnixHostReallyLocal (char *host)

{
char hostnamebuf[256];
char* xauthlocalname = getenv("XAUTHLOCALHOSTNAME");

TRANS(GetHostname) (hostnamebuf, sizeof (hostnamebuf));

@@ -1451,6 +1452,10 @@ UnixHostReallyLocal (char *host)
{
return (1);
}
else if(xauthlocalname && strcmp (xauthlocalname, host) == 0)
{
return (1);
}
else
{
/*

+ 3
- 1
dcop/dcopc.c View File

@@ -684,7 +684,9 @@ dcop_connect()
}

hostName[0] = '\0';
if (gethostname(hostName, sizeof(hostName)))
if (getenv("XAUTHLOCALHOSTNAME"))
strlcpy(hostName, getenv("XAUTHLOCALHOSTNAME"),sizeof(hostName)-1);
else if (gethostname(hostName, sizeof(hostName)))
strcpy(hostName, "localhost");
else
hostName[sizeof(hostName)-1] = '\0';

+ 3
- 1
dcop/dcopclient.cpp View File

@@ -277,7 +277,9 @@ static TQCString dcopServerFile(const TQCString &hostname, bool old)
{
char hostName[256];
hostName[0] = '\0';
if (gethostname(hostName, sizeof(hostName)))
if (getenv("XAUTHLOCALHOSTNAME"))
fName += getenv("XAUTHLOCALHOSTNAME");
else if (gethostname(hostName, sizeof(hostName)))
{
fName += "localhost";
}

+ 3
- 1
dcop/dcopserver_shutdown.c View File

@@ -95,7 +95,9 @@ static void getDCOPFile(char *dcop_file, char *dcop_file_old, int max_length)
strncat(dcop_file, "/.DCOPserver_", n);
n -= strlen("/.DCOPserver_");

if (gethostname(dcop_file+strlen(dcop_file), n) != 0)
if (getenv("XAUTHLOCALHOSTNAME"))
strncat(dcop_file+strlen(dcop_file), getenv("XAUTHLOCALHOSTNAME"), n);
else if (gethostname(dcop_file+strlen(dcop_file), n) != 0)
{
perror("Error. Could not determine hostname: ");
dcop_file[0] = '\0';

+ 1
- 1
interfaces/kimproxy/library/kimproxy.cpp View File

@@ -204,7 +204,7 @@ KIMProxy::KIMProxy( DCOPClient* dc ) : DCOPObject( "KIMProxyIface" ), TQObject()
// FIXME: make this work when the sender object id is set to KIMIFace
if ( !connectDCOPSignal( 0, 0, method, method, false ) )
KMessageBox::information( 0, TQString( "Couldn't connect DCOP signal.\nWon't receive any status notifications!" ) );
kdWarning() << "Couldn't connect DCOP signal. Won't receive any status notifications!" << endl;
}

KIMProxy::~KIMProxy( )

+ 2
- 2
interfaces/kmediaplayer/kfileaudiopreview/kfileaudiopreview.cpp View File

@@ -13,7 +13,7 @@
#include <kmimetype.h>
#include <kparts/componentfactory.h>

#include <kplayobjectfactory.h>
#include <kdemm/factory.h>

#include <config-kfile.h>

@@ -58,7 +58,7 @@ KFileAudioPreview::KFileAudioPreview( TQWidget *parent, const char *name )
{
KGlobal::locale()->insertCatalogue("kfileaudiopreview");

TQStringList formats = KDE::PlayObjectFactory::mimeTypes();
TQStringList formats = KDE::Multimedia::Factory::self()->playableMimeTypes();
// ###
TQStringList::ConstIterator it = formats.begin();
for ( ; it != formats.end(); ++it )

+ 3
- 3
kate/part/katehighlight.cpp View File

@@ -3225,7 +3225,7 @@ void KateHlManager::getDefaults(uint schema, KateAttributeList &list)
list.append(charAttribute);

KateAttribute* string = new KateAttribute();
string->setTextColor(TQColor::TQColor("#D00"));
string->setTextColor(TQColor("#D00"));
string->setSelectedTextColor(Qt::red);
list.append(string);

@@ -3242,9 +3242,9 @@ void KateHlManager::getDefaults(uint schema, KateAttributeList &list)

KateAttribute* alert = new KateAttribute();
alert->setTextColor(Qt::black);
alert->setSelectedTextColor( TQColor::TQColor("#FCC") );
alert->setSelectedTextColor( TQColor("#FCC") );
alert->setBold(true);
alert->setBGColor( TQColor::TQColor("#FCC") );
alert->setBGColor( TQColor("#FCC") );
list.append(alert);

KateAttribute* functionAttribute = new KateAttribute();

+ 1
- 1
kdecore/eventsrc View File

@@ -2572,7 +2572,7 @@ Comment[wa]=On messaedje critike est håyné
Comment[zh_CN]=正在显示关键消息
Comment[zh_HK]=顯示嚴重警告訊息
Comment[zh_TW]=嚴重的警告訊息已顯示
default_sound=KDE_Glass_Break.ogg
default_sound=KDE_Error_1.ogg
default_presentation=65
nopresentation=18
level=4

+ 2
- 0
kdecore/fakes.c View File

@@ -323,6 +323,7 @@ KDECORE_EXPORT int revoke(const char *tty)
#endif

#ifndef HAVE_STRLCPY
#include <string.h>
KDECORE_EXPORT unsigned long strlcpy(char* d, const char* s, unsigned long bufsize)
{
unsigned long len, ret = strlen(s);
@@ -341,6 +342,7 @@ KDECORE_EXPORT unsigned long strlcpy(char* d, const char* s, unsigned long bufsi
#endif

#ifndef HAVE_STRLCAT
#include <string.h>
KDECORE_EXPORT unsigned long strlcat(char* d, const char* s, unsigned long bufsize)
{
char *cp;

+ 17
- 3
kdecore/kapplication.cpp View File

@@ -41,6 +41,7 @@
#include <tqtooltip.h>
#include <tqstylefactory.h>
#include <tqmetaobject.h>
#include <tqimage.h>
#ifndef QT_NO_SQL
#include <tqsqlpropertymap.h>
#endif
@@ -87,6 +88,8 @@
#include <sys/stat.h>
#endif
#include <sys/wait.h>
#include <grp.h>
#include <sys/types.h>

#ifndef Q_WS_WIN
#include "kwin.h"
@@ -776,10 +779,15 @@ void KApplication::init(bool GUIenabled)
{
d->guiEnabled = GUIenabled;
if ((getuid() != geteuid()) ||
(getgid() != getegid()))
(getgid() != getegid()) )
{
fprintf(stderr, "The KDE libraries are not designed to run with suid privileges.\n");
::exit(127);
// man permissions are not exploitable and better than
// world writable directories
struct group *man = getgrnam("man");
if ( !man || man->gr_gid != getegid() ){
fprintf(stderr, "The KDE libraries are not designed to run with suid privileges.\n");
::exit(127);
}
}

KProcessController::ref();
@@ -2137,6 +2145,12 @@ void KApplication::propagateSettings(SettingsCategory arg)
KConfigBase* config = KGlobal::config();
KConfigGroupSaver saver( config, "KDE" );

#ifdef QT_HAVE_MAX_IMAGE_SIZE
TQSize maxImageSize(4096, 4096);
maxImageSize = config->readSizeEntry("MaxImageSize", &maxImageSize);
TQImage::setMaxImageSize(maxImageSize);
#endif

int num = config->readNumEntry("CursorBlinkRate", TQApplication::cursorFlashTime());
if ((num != 0) && (num < 200))
num = 200;

+ 5
- 1
kdecore/kcatalogue.cpp View File

@@ -66,7 +66,11 @@ KCatalogue::KCatalogue(const TQString & name, const TQString & language )
.arg( d->language )
.arg( d->name );

setFileName( locate( "locale", path ) );
TQString fileName = locate( "locale", path );
if (fileName.isEmpty())
fileName = locate( "locale-bundle", path );

setFileName( fileName );
}


+ 18
- 0
kdecore/kconfigbase.cpp View File

@@ -131,6 +131,24 @@ bool KConfigBase::hasKey(const char *pKey) const
return !entry.mValue.isNull();
}

bool KConfigBase::hasTranslatedKey(const char* pKey) const
{
KEntryKey aEntryKey(mGroup, 0);
aEntryKey.c_key = pKey;
aEntryKey.bDefault = readDefaults();

if (!locale().isNull()) {
// try the localized key first
aEntryKey.bLocal = true;
KEntry entry = lookupData(aEntryKey);
if (!entry.mValue.isNull())
return true;
aEntryKey.bLocal = false;
}

return false;
}

bool KConfigBase::hasGroup(const TQString &group) const
{
return internalHasGroup( group.utf8());

+ 1
- 0
kdecore/kconfigbase.h View File

@@ -1985,6 +1985,7 @@ public:

protected:
TQCString readEntryUtf8( const char *pKey) const;
bool hasTranslatedKey( const char *pKey ) const;

/**
* The currently selected group. */

+ 3
- 1
kdecore/kcrash.cpp View File

@@ -466,7 +466,9 @@ static int openSocket()
sock_file[strlen(sock_file)-1] = 0;
strncat(sock_file, "/socket-", MAX_SOCK_FILE - strlen(sock_file));
if (gethostname(sock_file+strlen(sock_file), MAX_SOCK_FILE - strlen(sock_file) - 1) != 0)
if( getenv("XAUTHLOCALHOSTNAME"))
strncat(sock_file, getenv("XAUTHLOCALHOSTNAME"), MAX_SOCK_FILE - strlen(sock_file) - 1);
else if (gethostname(sock_file+strlen(sock_file), MAX_SOCK_FILE - strlen(sock_file) - 1) != 0)
{
perror("Warning: Could not determine hostname: ");
return -1;

+ 26
- 5
kdecore/kdesktopfile.cpp View File

@@ -34,6 +34,8 @@
#include "kapplication.h"
#include "kstandarddirs.h"
#include "kmountpoint.h"
#include "kcatalogue.h"
#include "klocale.h"

#include "kdesktopfile.h"
#include "kdesktopfile.moc"
@@ -145,6 +147,27 @@ bool KDesktopFile::isAuthorizedDesktopFile(const TQString& path)
return false;
}

TQString KDesktopFile::translatedEntry(const char* key) const
{
if (hasTranslatedKey(key))
return readEntry(key);

if (hasKey(key)) {
TQString value = readEntryUntranslated(key);
TQString fName = fileName();
fName = fName.mid(fName.findRev('/')+1);
TQString po_lookup_key = TQString::fromLatin1(key) + "(" + fName + "): " + value;
TQString po_value = KGlobal::locale()->translate(po_lookup_key.utf8().data());

if (po_value == po_lookup_key)
return value;

return po_value;
}

return TQString::null;
}

TQString KDesktopFile::readType() const
{
return readEntry("Type");
@@ -157,17 +180,17 @@ TQString KDesktopFile::readIcon() const

TQString KDesktopFile::readName() const
{
return readEntry("Name");
return translatedEntry("Name");
}

TQString KDesktopFile::readComment() const
{
return readEntry("Comment");
return translatedEntry("Comment");
}

TQString KDesktopFile::readGenericName() const
{
return readEntry("GenericName");
return translatedEntry("GenericName");
}

TQString KDesktopFile::readPath() const
@@ -342,5 +365,3 @@ KDesktopFile* KDesktopFile::copyTo(const TQString &file) const
config->setDesktopGroup();
return config;
}



+ 2
- 0
kdecore/kdesktopfile.h View File

@@ -236,6 +236,8 @@ private:

private:

TQString translatedEntry(const char*) const;

// copy-construction and assignment are not allowed
KDesktopFile( const KDesktopFile& );
KDesktopFile& operator= ( const KDesktopFile& );

+ 8
- 1
kdecore/klocale.cpp View File

@@ -408,7 +408,11 @@ TQString KLocale::catalogueFileName(const TQString & language,
.arg( language )
.arg( catalog.name() );

return locate( "locale", path );
TQString fileName = locate( "locale", path );
if (fileName.isEmpty())
fileName = locate( "locale-bundle", path );

return fileName;
}

bool KLocale::setLanguage(const TQString & language)
@@ -507,6 +511,9 @@ bool KLocale::isApplicationTranslatedInto( const TQString & language)
// kdDebug() << "isApplicationTranslatedInto: filename " << sFileName << endl;

TQString sAbsFileName = locate( "locale", sFileName );
if (sAbsFileName.isEmpty())
sAbsFileName = locate( "locale-bundle", sFileName );

// kdDebug() << "isApplicationTranslatedInto: absname " << sAbsFileName << endl;
return ! sAbsFileName.isEmpty();
}

+ 13
- 4
kdecore/kstandarddirs.cpp View File

@@ -94,13 +94,13 @@ KStandardDirsSingleton* KStandardDirsSingleton::self() {
return s_self;
}

static const char* const types[] = {"html", "icon", "apps", "sound",
"data", "locale", "services", "mime",
static const char* const types[] = {"html", "html-bundle", "icon", "apps", "sound",
"data", "locale", "locale-bundle", "services", "mime",
"servicetypes", "config", "exe",
"wallpaper", "lib", "pixmap", "templates",
"module", "qtplugins",
"xdgdata-apps", "xdgdata-dirs", "xdgconf-menu",
"xdgdata-icon", "xdgdata-pixmap",
"xdgdata-icon", "xdgdata-pixmap", "xdgconf-autostart",
"kcfg", "emoticons", 0 };

static int tokenize( TQStringList& token, const TQString& str,
@@ -719,7 +719,10 @@ void KStandardDirs::createSpecialResource(const char *type)
{
char hostname[256];
hostname[0] = 0;
gethostname(hostname, 255);
if( getenv("XAUTHLOCALHOSTNAME"))
strlcpy(hostname, getenv("XAUTHLOCALHOSTNAME"), 255 );
else
gethostname(hostname, 255);
TQString dir = TQString("%1%2-%3").arg(localkdedir()).arg(type).arg(hostname);
char link[1024];
link[1023] = 0;
@@ -1024,6 +1027,8 @@ static int tokenize( TQStringList& tokens, const TQString& str,
TQString KStandardDirs::kde_default(const char *type) {
if (!strcmp(type, "data"))
return "share/apps/";
if (!strcmp(type, "html-bundle"))
return "share/doc-bundle/HTML/";
if (!strcmp(type, "html"))
return "share/doc/kde/HTML/";
if (!strcmp(type, "icon"))
@@ -1036,6 +1041,8 @@ TQString KStandardDirs::kde_default(const char *type) {
return "share/applnk/";
if (!strcmp(type, "sound"))
return "share/sounds/";
if (!strcmp(type, "locale-bundle"))
return "share/locale-bundle/";
if (!strcmp(type, "locale"))
return "share/locale/";
if (!strcmp(type, "services"))
@@ -1068,6 +1075,8 @@ TQString KStandardDirs::kde_default(const char *type) {
return "desktop-directories/";
if (!strcmp(type, "xdgconf-menu"))
return "menus/";
if (!strcmp(type, "xdgconf-autostart"))
return "autostart/";
if (!strcmp(type, "kcfg"))
return "share/config.kcfg";
if (!strcmp(type, "emoticons"))

+ 3
- 1
kdecore/kwinmodule.cpp View File

@@ -436,7 +436,9 @@ TQRect KWinModule::workArea( const TQValueList<WId>& exclude, int desktop ) cons
if ( strut.bottom > 0 )
r.setBottom( r.bottom() - (int) strut.bottom );

a = a.intersect(r);
TQRect tmp;
tmp = a.intersect(r);
a = tmp;
}
return a;
}

+ 5
- 1
kded/Makefile.am View File

@@ -36,12 +36,16 @@ kbuildsycoca_la_SOURCES = kbuildsycoca.cpp kbuildservicetypefactory.cpp \
kctimefactory.cpp \
vfolder_menu.cpp

bin_PROGRAMS = kdontchangethehostname kde-menu
bin_PROGRAMS = kdontchangethehostname kde-menu kmimelist

kdontchangethehostname_LDFLAGS = $(all_libraries) $(KDE_RPATH)
kdontchangethehostname_LDADD = $(LIB_KDECORE)
kdontchangethehostname_SOURCES = khostname.cpp

kmimelist_LDFLAGS = $(all_libraries) $(KDE_RPATH)
kmimelist_LDADD = ../kio/libkio.la
kmimelist_SOURCES = kmimelist.cpp

kde_menu_LDFLAGS = $(all_libraries) $(KDE_RPATH)
kde_menu_LDADD = $(LIB_KIO)
kde_menu_SOURCES = kde-menu.cpp

+ 18
- 10
kded/khostname.cpp View File

@@ -111,7 +111,8 @@ static QCStringList split(const TQCString &str)

void KHostName::changeX()
{
TQString cmd = "xauth list";
const char* xauthlocalhostname = getenv("XAUTHLOCALHOSTNAME");
TQString cmd = "xauth -n list";
FILE *xFile = popen(TQFile::encodeName(cmd), "r");
if (!xFile)
{
@@ -123,6 +124,7 @@ void KHostName::changeX()
char buf[1024+1];
while (!feof(xFile))
{
buf[1024]='\0';
TQCString line = fgets(buf, 1024, xFile);
if (line.length())
line.truncate(line.length()-1); // Strip LF.
@@ -157,12 +159,17 @@ void KHostName::changeX()
TQCString newNetId = newName+netId.mid(i);
TQCString oldNetId = netId.left(i);

if(oldNetId != oldName)
continue;
if(oldNetId != oldName
&& (!xauthlocalhostname || strcmp(xauthlocalhostname, oldNetId.data()) != 0))
continue;

cmd = "xauth remove "+KProcess::quote(netId);
system(TQFile::encodeName(cmd));
cmd = "xauth add ";
// don't nuke the xauth when XAUTHLOCALHOSTNAME points to it
if (!xauthlocalhostname || oldNetId != xauthlocalhostname)
{
cmd = "xauth -n remove "+KProcess::quote(netId);
system(TQFile::encodeName(cmd));
}
cmd = "xauth -n add ";
cmd += KProcess::quote(newNetId);
cmd += " ";
cmd += KProcess::quote(authName);
@@ -276,7 +283,10 @@ void KHostName::changeDcop()
}
}

// Remove old entries
// Remove old entries, but only if XAUTHLOCALHOSTNAME doesn't point
// to it
char* xauthlocalhostname = getenv("XAUTHLOCALHOSTNAME");
if (!xauthlocalhostname || !oldNetId.contains(xauthlocalhostname))
{
TQString cmd = "iceauth remove "+KProcess::quote("netid="+oldNetId);
system(TQFile::encodeName(cmd));
@@ -368,9 +378,7 @@ int main(int argc, char **argv)

KHostName hn;

if(!getenv("XAUTHLOCALHOSTNAME"))
hn.changeX();

hn.changeX();
hn.changeDcop();
hn.changeStdDirs("socket");
hn.changeStdDirs("tmp");

+ 54
- 0
kded/kmimelist.cpp View File

@@ -0,0 +1,54 @@
#include <ktrader.h>
#include <kservice.h>
#include <kmimetype.h>
#include <assert.h>
#include <kstandarddirs.h>
#include <kservicegroup.h>
#include <kimageio.h>
#include <kuserprofile.h>
#include <kprotocolinfo.h>

#include <kapplication.h>

#include <stdio.h>

int main(int argc, char *argv[])
{
KApplication k(argc,argv,"blurb",false);

KMimeType::List mtl = KMimeType::allMimeTypes( );
assert( mtl.count() );
qDebug( "Found %d mime types.", mtl.count() );
TQValueListIterator<KMimeType::Ptr> it(mtl.begin());
KServiceTypeProfile::OfferList ol;

for (; it != mtl.end(); ++it)
{
{
// Application
printf( "APP:%s:", (*it)->name().latin1() );
ol = KServiceTypeProfile::offers((*it)->name(), "Application");
TQValueListIterator<KServiceOffer> it2(ol.begin());
for (; it2 != ol.end(); ++it2) {
if ((*it2).allowAsDefault())
printf( " %s", (*it2).service()->desktopEntryPath().ascii() );

}
printf( "\n" );
}

{
// Embedded
printf( "PART:%s:", (*it)->name().latin1() );
ol = KServiceTypeProfile::offers((*it)->name(), "KParts/ReadOnlyPart");
TQValueListIterator<KServiceOffer> it2(ol.begin());
for (; it2 != ol.end(); ++it2) {
if ((*it2).allowAsDefault())
printf( " %s", (*it2).service()->desktopEntryPath().ascii() );

}
printf( "\n" );
}
}
}


+ 58
- 17
kdefx/kstyle.cpp View File

@@ -31,6 +31,7 @@

#include <tqapplication.h>
#include <tqbitmap.h>
#include <tqmetaobject.h>
#include <tqcleanuphandler.h>
#include <tqmap.h>
#include <tqimage.h>
@@ -79,7 +80,7 @@ namespace
TQWidget* w1;
TQWidget* w2;
};
typedef TQMap<const TQPopupMenu*,ShadowElements> ShadowMap;
typedef TQMap<const TQWidget*,ShadowElements> ShadowMap;
static ShadowMap *_shadowMap = 0;
TQSingleCleanupHandler<ShadowMap> cleanupShadowMap;
ShadowMap &shadowMap() {
@@ -113,8 +114,13 @@ namespace

const double shadow_strip[4] =
{ 0.565, 0.675, 0.835, 0.945 };
}

static bool useDropShadow(TQWidget* w)
{
return w && w->metaObject() &&
w->metaObject()->findProperty("KStyleMenuDropShadow") != -1;
}
}

namespace
{
@@ -128,12 +134,12 @@ class TransparencyHandler : public QObject

protected:
void blendToColor(const TQColor &col);
void blendToPixmap(const TQColorGroup &cg, const TQPopupMenu* p);
void blendToPixmap(const TQColorGroup &cg, const TQWidget* p);
#ifdef HAVE_XRENDER
void XRenderBlendToPixmap(const TQPopupMenu* p);
void XRenderBlendToPixmap(const TQWidget* p);
#endif
void createShadowWindows(const TQPopupMenu* p);
void removeShadowWindows(const TQPopupMenu* p);
void createShadowWindows(const TQWidget* p);
void removeShadowWindows(const TQWidget* p);
void rightShadow(TQImage& dst);
void bottomShadow(TQImage& dst);
private:
@@ -256,8 +262,16 @@ void KStyle::polish( TQWidget* widget )
widget->installEventFilter(this);
}
}
}
if (widget->isTopLevel())
{
if (!d->menuHandler && useDropShadow(widget))
d->menuHandler = new TransparencyHandler(this, Disabled, 1.0, false);

if (d->menuHandler && useDropShadow(widget))
widget->installEventFilter(d->menuHandler);
}
}

void KStyle::unPolish( TQWidget* widget )
{
@@ -267,8 +281,10 @@ void KStyle::unPolish( TQWidget* widget )
TQFrame::Shape shape = frame->frameShape();
if (shape == TQFrame::ToolBarPanel || shape == TQFrame::MenuBarPanel)
widget->removeEventFilter(this);
}
}
}
if (widget->isTopLevel() && d->menuHandler && useDropShadow(widget))
widget->removeEventFilter(d->menuHandler);
}


@@ -2016,7 +2032,7 @@ void TransparencyHandler::bottomShadow(TQImage& dst)
}

// Create a shadow of thickness 4.
void TransparencyHandler::createShadowWindows(const TQPopupMenu* p)
void TransparencyHandler::createShadowWindows(const TQWidget* p)
{
#ifdef Q_WS_X11
int x2 = p->x()+p->width();
@@ -2063,7 +2079,7 @@ void TransparencyHandler::createShadowWindows(const TQPopupMenu* p)
#endif
}

void TransparencyHandler::removeShadowWindows(const TQPopupMenu* p)
void TransparencyHandler::removeShadowWindows(const TQWidget* p)
{
#ifdef Q_WS_X11
ShadowMap::iterator it = shadowMap().find(p);
@@ -2089,7 +2105,7 @@ bool TransparencyHandler::eventFilter( TQObject* object, TQEvent* event )
// Copyright (C) 2000 Daniel M. Duley <mosfet@kde.org>

// Added 'fake' menu shadows <04-Jul-2002> -- Karol
TQPopupMenu* p = (TQPopupMenu*)object;
TQWidget* p = (TQWidget*)object;
TQEvent::Type et = event->type();

if (et == TQEvent::Show)
@@ -2128,13 +2144,23 @@ bool TransparencyHandler::eventFilter( TQObject* object, TQEvent* event )
// * shadows after duplicate show events.
// * TODO : determine real cause for duplicate events
// * till 20021005
if (dropShadow && p->width() > 16 && p->height() > 16 && !shadowMap().contains( p ))
if ((dropShadow || useDropShadow(p))
&& p->width() > 16 && p->height() > 16 && !shadowMap().contains( p ))
createShadowWindows(p);
}
else if (et == TQEvent::Resize && p->isShown() && p->isTopLevel())
{
// Handle drop shadow
if (dropShadow || useDropShadow(p))
{
removeShadowWindows(p);
createShadowWindows(p);
}
}
else if (et == TQEvent::Hide)
{
// Handle drop shadow
if (dropShadow)
if (dropShadow || useDropShadow(p))
removeShadowWindows(p);

// Handle translucency
@@ -2159,7 +2185,7 @@ void TransparencyHandler::blendToColor(const TQColor &col)
}


void TransparencyHandler::blendToPixmap(const TQColorGroup &cg, const TQPopupMenu* p)
void TransparencyHandler::blendToPixmap(const TQColorGroup &cg, const TQWidget* p)
{
if (opacity < 0.0 || opacity > 1.0)
return;
@@ -2172,7 +2198,10 @@ void TransparencyHandler::blendToPixmap(const TQColorGroup &cg, const TQPopupMen
return;

// Allow styles to define the blend pixmap - allows for some interesting effects.
kstyle->renderMenuBlendPixmap( blendPix, cg, p );
if (::qt_cast<TQPopupMenu*>(p))
kstyle->renderMenuBlendPixmap( blendPix, cg, ::qt_cast<TQPopupMenu*>(p) );
else
blendPix.fill(cg.button()); // Just tint as the default behavior

TQImage blendImg = blendPix.convertToImage();
TQImage backImg = pix.convertToImage();
@@ -2185,13 +2214,17 @@ void TransparencyHandler::blendToPixmap(const TQColorGroup &cg, const TQPopupMen
// Here we go, use XRender in all its glory.
// NOTE: This is actually a bit slower than the above routines
// on non-accelerated displays. -- Karol.
void TransparencyHandler::XRenderBlendToPixmap(const TQPopupMenu* p)
void TransparencyHandler::XRenderBlendToPixmap(const TQWidget* p)
{
KPixmap renderPix;
renderPix.resize( pix.width(), pix.height() );

// Allow styles to define the blend pixmap - allows for some interesting effects.
kstyle->renderMenuBlendPixmap( renderPix, p->colorGroup(), p );
if (::qt_cast<TQPopupMenu*>(p))
kstyle->renderMenuBlendPixmap( renderPix, p->colorGroup(),
::qt_cast<TQPopupMenu*>(p) );
else
renderPix.fill(p->colorGroup().button()); // Just tint as the default behavior

Display* dpy = qt_xdisplay();
Pixmap alphaPixmap;
@@ -2229,6 +2262,14 @@ void TransparencyHandler::XRenderBlendToPixmap(const TQPopupMenu* p)
void KStyle::virtual_hook( int, void* )
{ /*BASE::virtual_hook( id, data );*/ }

// HACK for gtk-qt-engine

KDE_EXPORT extern "C"
void kde_kstyle_set_scrollbar_type_windows( void* style )
{
((KStyle*)style)->setScrollBarType( KStyle::WindowsStyleScrollBar );
}

// vim: set noet ts=4 sw=4:
// kate: indent-width 4; replace-tabs off; tab-width 4; space-indent off;


BIN
kdemm/0.png View File


+ 31
- 0
kdemm/DESIGN View File

@@ -0,0 +1,31 @@
There should be at least two libs:
1. kdemm(core)
==============

Provides the wrapper for the media framework and all needed media functionality.
Whether this lib needs to depend on kdeui? Depends on how we could handle video
without UI... but if possible we should put the video-widget in kdemmwidgets.

The Requirements & Specification document can be found in reqspec.html


2. kdemmwidgets
===============

Provides convenience widgets for the common widgets that are needed:
- Position slider (display position and move it to seek)
- Volume fader
- Effects dialog (including EQ)
- Video widget
- Player controls as toolbar


Also there could be a KPart:
3. kdemmpart
============

A KPart implementing the KMediaPlayer interface.



// vim: tw=80

+ 43
- 0
kdemm/Makefile.am View File

@@ -0,0 +1,43 @@
# This file is part of the KDE libraries
# Copyright (C) 2004 Matthias Kretz <kretz@kde.org>

# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public
# License version 2 as published by the Free Software Foundation.

# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Library General Public License for more details.

# You should have received a copy of the GNU Library General Public License
# along with this library; see the file COPYING.LIB. If not, write to
# the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.

INCLUDES = -I$(top_srcdir)/kdecore -I$(top_srcdir)/kio $(all_includes)

SUBDIRS = . test

lib_LTLIBRARIES = libkdemm.la

kdemmincludedir = $(includedir)/kdemm
kdemminclude_HEADERS = backend.h factory.h player.h channel.h videoplayer.h mixeriface.h simpleplayer.h

libkdemm_la_SOURCES = backend.cpp factory.cpp player.cpp channel.cpp videoplayer.cpp mixeriface.skel simpleplayer.cpp factory.skel

libkdemm_la_LDFLAGS = $(QT_LDFLAGS) $(KDE_RPATH) $(KDE_MT_LDFLAGS) $(USER_LDFLAGS) -version-info 0:0:0 -no-undefined
libkdemm_la_LIBADD = ../kdecore/libkdecore.la ../kio/libkio.la

factory_DCOPIDLNG = true

METASOURCES = AUTO

kde_servicetypes_DATA = mmbackendinfo.desktop

SRCDOC_DEST=$(kde_htmldir)/en/kdelibs/kdemm

DOXYGEN_REFERENCES = dcop kdecore kio

include ../admin/Doxyfile.am


+ 27
- 0
kdemm/TODO View File

@@ -0,0 +1,27 @@
Factory
- get a list of available backends
- be able to choose the one you want to use, overriding the KTrader information
- test on the fly switching

Audio
- function to retrieve the PCM data that currently is played (could be done in
the Channel as well as in the Player)

Video
- either a new interface or somehow integrate into the player
If it's a new interface we have to copy most of the Player class, which I
wouldn't like to see.

two wrapper APIs:
- for notifications
play file and don't care
automatically use the notification channel if present
- for simple players
open file and provide seek and volume

Mixer abstraction
- provide access to the hardware mixer and/or the mixer of the backend
- provide access to software volume controls (like the Channels)

Record Interface
- simple PCM recording API

+ 78
- 0
kdemm/backend.cpp View File

@@ -0,0 +1,78 @@
/* This file is part of the KDE project
Copyright (C) 2004 Matthias Kretz <kretz@kde.org>

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License version 2 as published by the Free Software Foundation.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.

You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.

*/

#include "backend.h"
#include "player.h"

#include <tqstringlist.h>

#include <kglobal.h>
#include <kinstance.h>
#include <kaboutdata.h>

namespace KDE
{
namespace Multimedia
{

class Backend::Private
{
public:
Channel * channel;
};

Backend::Backend( TQObject * parent, const char * name )
: TQObject( parent, name )
, d( 0 )
{
}

Backend::~Backend()
{
delete d;
}

bool Backend::playSoundEvent( const KURL & url )
{
if( ! d )
{
d = new Private;

TQString ctype = "notifications";
if( availableChannels( Channel::Output ).contains( ctype ) < 1 )
ctype = "default";
d->channel = createChannel( KGlobal::instance()->aboutData()->programName(), ctype, Channel::Output );
}

Player * player = createPlayer();
player->setOutputChannel( d->channel );
connect( player, TQT_SIGNAL( finished() ), player, TQT_SLOT( deleteLater() ) );

if( player->load( url ) )
if( player->play() )
return true;
delete player;
return false;
}

}} // namespaces

#include "backend.moc"

// vim: sw=4 ts=4 noet

+ 86
- 0
kdemm/backend.h View File

@@ -0,0 +1,86 @@
/* This file is part of the KDE project
Copyright (C) 2004 Matthias Kretz <kretz@kde.org>

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License version 2 as published by the Free Software Foundation.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.

You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.

*/

#ifndef BACKEND_H
#define BACKEND_H

#include <tqobject.h>
#include <kdemacros.h>
#include <kdemm/channel.h>
#include <kurl.h>

namespace KDE
{
namespace Multimedia
{
class Player;
class VideoPlayer;
/**
* \brief Base class for all KDE Multimedia Backends
*
* This class provides the interface for Multimedia Backends. Use it to get
* a pointer to a new Player or VideoWidget. There are some reserved
* functions for later extension of the class.
*
* \author Matthias Kretz <kretz@kde.org>
* \since 4.0
*/
class Backend : public QObject
{
Q_OBJECT
public:
/**
* default TQObject constructor
*/
Backend( TQObject * parent = 0, const char * name = 0 );
virtual ~Backend();

/**
* @return A new instance to a Player from the Backend.
*/
virtual Player * createPlayer() = 0;

/**
* Create a new VideoPlayer object. The Backend does not have to
* implement this function.
*
* @return A new instance to a VideoPlayer from the Backend. Or 0 if
* the Backend does not support the VideoPlayer interface.
*/
virtual VideoPlayer * createVideoPlayer() { return 0; }

virtual bool playSoundEvent(const KURL & url);

virtual Channel * createChannel( const TQString & title, const TQString & channeltype,
Channel::Direction direction ) = 0;

virtual TQStringList availableChannels( Channel::Direction direction ) const = 0;

virtual TQStringList playableMimeTypes() const = 0;

private:
RESERVE_VIRTUAL_10

class Private;
Private * d;
};
}} // namespaces

// vim: sw=4 ts=4 noet tw=80
#endif // BACKEND_H

+ 69
- 0
kdemm/channel.cpp View File

@@ -0,0 +1,69 @@
/* This file is part of the KDE project
Copyright (C) 2004 Scott Wheeler <wheeler@kde.org>

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License version 2 as published by the Free Software Foundation.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.

You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.

*/

#include "channel.h"

#include <tqstring.h>

namespace KDE
{
namespace Multimedia
{

class Channel::Private
{
public:
TQString channelName;
TQString channelType;
Direction direction;
};

Channel::Channel( const TQString & channelName, const TQString & type, Direction direction,
TQObject * parent, const char * name )
: TQObject( parent, name )
{
d = new Private;
d->channelName = channelName;
d->channelType = type;
d->direction = direction;
}

Channel::~Channel()
{
delete d;
}

TQString Channel::channelName() const
{
return d->channelName;
}

TQString Channel::channelType() const
{
return d->channelType;
}

Channel::Direction Channel::direction() const
{
return d->direction;
}

}}
#include "channel.moc"
// vim: sw=4 ts=4 noet

+ 96
- 0
kdemm/channel.h View File

@@ -0,0 +1,96 @@
/* This file is part of the KDE project
Copyright (C) 2004 Matthias Kretz <kretz@kde.org>

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License version 2 as published by the Free Software Foundation.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.

You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.

*/

#ifndef KDEMM_CHANNEL_H
#define KDEMM_CHANNEL_H

#include <kdemm/mixeriface.h>

class TQString;

namespace KDE
{
namespace Multimedia
{
/**
* \short Abstraction of different inputs or outputs
*
* \author Matthias Kretz <kretz@kde.org>
* \since 4.0
*/
class KDE_EXPORT Channel : public TQObject, virtual public MixerIface
{
Q_OBJECT
public:
virtual ~Channel();

enum Direction
{
Input,
Output
};

/**
* The user visible name of the channel
*/
virtual TQString channelName() const;

/**
* The (internal) channel type.
*/
virtual TQString channelType() const;

/**
* Whether it is an Input or Output channel
*/
virtual Direction direction() const;

/**
* If the channel has a volume control this function returns \p true
*/
virtual bool hasVolumeControl() const = 0;
/**
* The current volume of the channel
*/
virtual float volume() const = 0;

/**
* Set the volume for the channel
*
* \returns Returns \p true if the volume has been successfully set
*/
virtual bool setVolume( float volume ) = 0;

protected:
/**
* You can not instantiate channels yourself, use the Factory to
* create them.
*/
Channel( const TQString & channelName, const TQString & type, Direction direction,
TQObject * parent = 0, const char * name = 0 );

private:
class Private;
Private * d;
};
}} // namespaces
// vim: sw=4 ts=4 noet tw=80

#endif // KDEMM_CHANNEL_H

+ 296
- 0
kdemm/factory.cpp View File

@@ -0,0 +1,296 @@
/* This file is part of the KDE project
Copyright (C) 2004 Matthias Kretz <kretz@kde.org>

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License version 2 as published by the Free Software Foundation.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.

You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.

*/

#include "factory.h"
#include "backend.h"
#include "player.h"
#include "videoplayer.h"
#include "channel.h"

#include <ktrader.h>
#include <kservice.h>
#include <klibloader.h>
#include <kmessagebox.h>
#include <tqfile.h>
#include <klocale.h>
#include <kmimetype.h>
#include <kdebug.h>

namespace KDE
{
namespace Multimedia
{
class Factory::Private
{
public:
Private()
: backend( 0 )
{
createBackend();
}

void createBackend()
{
KTrader::OfferList offers = KTrader::self()->query( "KDEMultimediaBackend", "Type == 'Service'" );
KTrader::OfferListIterator it = offers.begin();
KTrader::OfferListIterator end = offers.end();
TQStringList errormsg;
for( ; it != end; ++it )
{
KService::Ptr ptr = *it;
KLibFactory * factory = KLibLoader::self()->factory( TQFile::encodeName( ptr->library() ) );
if( factory )
{
backend = ( Backend* )factory->create( 0, "Multimedia Backend", "KDE::Multimedia::Backend" );
if( 0 == backend )
{
TQString e = i18n( "create method returned 0" );
errormsg.append( e );
kdDebug( 600 ) << "Error getting backend from factory for " <<
ptr->name() << ":\n" << e << endl;
}
else
{
service = ptr;
kdDebug( 600 ) << "using backend: " << ptr->name() << endl;
break;
}
}
else
{
TQString e = KLibLoader::self()->lastErrorMessage();
errormsg.append( e );
kdDebug( 600 ) << "Error getting factory for " << ptr->name() <<
":\n" << e << endl;
}
}
#if 0
if( 0 == backend )
{
if( offers.size() == 0 )
KMessageBox::error( 0, i18n( "Unable to find a Multimedia Backend" ) );
else
{
TQString details = "<qt><table>";
TQStringList::Iterator eit = errormsg.begin();
TQStringList::Iterator eend = errormsg.end();
KTrader::OfferListIterator oit = offers.begin();
KTrader::OfferListIterator oend = offers.end();
for( ; eit != eend || oit != oend; ++eit, ++oit )
details += TQString( "<tr><td><b>%1</b></td><td>%2</td></tr>" )
.arg( ( *oit )->name() ).arg( *eit );
details += "</table></qt>";

KMessageBox::detailedError( 0,
i18n( "Unable to use any of the available Multimedia Backends" ), details );
}
}
#endif
}

Backend * backend;
KService::Ptr service;

TQValueList<void*> objects;
};

Factory * Factory::m_self = 0;

Factory * Factory::self()
{
if( ! m_self )
m_self = new Factory();
return m_self;
}

Factory::Factory()
: DCOPObject( "KDEMMFactory" )
, d( new Private )
{
connectDCOPSignal( 0, 0, "kdemmBackendChanged()", "kdemmBackendChanged()", false);
}

Factory::~Factory()
{
delete d;
}

void Factory::kdemmBackendChanged()
{
if( d->backend )
{
// wouw, if we want to switch on the fly we have to exchange the
// (Video)Player and Channel classes without the API user noticing. That
// would mean to implement a kind of smartwrapper:
// Player: Interface that accesses Player_skel which is abstract and is
// implemented by the Backend. The API user would only get access to the
// Player class and if you want to switch the backend you can delete the
// Player_skel object and put another implementation in its place.
//
// Now we tell the kdemm using app to help us. With the first signal we
// tell 'em to delete all the (Video)Players and Channels and with the
// second to recreate them all again.
emit deleteYourObjects();
if( d->objects.size() > 0 )
{
kdWarning( 600 ) << "we were asked to change the backend but the application did\n"
"not free all references to objects created by the factory. Therefor we can not\n"
"change the backend without crashing. Now we have to wait for a restart to make\n"
"backendswitching possible." << endl;
// in case there were objects deleted give 'em a chance to recreate
// them now
emit recreateObjects();
return;
}
delete d->backend;
d->backend = 0;
}
d->createBackend();
emit recreateObjects();
}

void Factory::objectDestroyed( TQObject * obj )
{
kdDebug( 600 ) << k_funcinfo << obj << endl;
void * p = ( void* )obj;
d->objects.remove( p );
}

Player * Factory::createPlayer()
{
if( d->backend )
{
Player * p = d->backend->createPlayer();
connect( p, TQT_SIGNAL( destroyed( TQObject* ) ), TQT_SLOT( objectDestroyed( TQObject* ) ) );
d->objects.append( p );
return p;
}
else
return 0;
}

VideoPlayer * Factory::createVideoPlayer()
{
if( d->backend )
{
VideoPlayer * vp = d->backend->createVideoPlayer();
connect( vp, TQT_SIGNAL( destroyed( TQObject* ) ), TQT_SLOT( objectDestroyed( TQObject* ) ) );
d->objects.append( vp );
return vp;
}
else
return 0;
}

bool Factory::playSoundEvent(const KURL & url)
{
if( d->backend )
return d->backend->playSoundEvent(url);
else
return false;
}

Channel * Factory::createChannel( const TQString & title, const TQString & channeltype,
Channel::Direction direction )
{
if( d->backend )
{
Channel * c = d->backend->createChannel( title, channeltype, direction );
connect( c, TQT_SIGNAL( destroyed( TQObject* ) ), TQT_SLOT( objectDestroyed( TQObject* ) ) );
d->objects.append( c );
return c;
}
else
return 0;
}

TQStringList Factory::availableChannels( Channel::Direction direction ) const
{
if( d->backend )
return d->backend->availableChannels( direction );
else
return TQStringList();
}

TQStringList Factory::playableMimeTypes() const
{
if( d->backend )
return d->backend->playableMimeTypes();
else
return TQStringList();
}

bool Factory::isMimeTypePlayable( const TQString & type ) const
{
if( d->backend )
{
KMimeType::Ptr mimetype = KMimeType::mimeType( type );
TQStringList mimetypes = playableMimeTypes();
for( TQStringList::ConstIterator i=mimetypes.begin(); i!=mimetypes.end(); i++ )
if( mimetype->is( *i ) )
return true;
}
return false;
}

TQString Factory::backendName() const
{
if( d->service )
return d->service->name();
else
return TQString::null;
}

TQString Factory::backendComment() const
{
if( d->service )
return d->service->comment();
else
return TQString::null;
}

TQString Factory::backendVersion() const
{
if( d->service )
return d->service->property( "X-KDE-MMBackendInfo-Version" ).toString();
else
return TQString::null;
}

TQString Factory::backendIcon() const
{
if( d->service )
return d->service->icon();
else
return TQString::null;
}

TQString Factory::backendWebsite() const
{
if( d->service )
return d->service->property( "X-KDE-MMBackendInfo-Website" ).toString();
else
return TQString::null;
}

}} //namespaces

#include "factory.moc"

// vim: sw=4 ts=4 noet

+ 222
- 0
kdemm/factory.h View File

@@ -0,0 +1,222 @@
/* This file is part of the KDE project
Copyright (C) 2004 Matthias Kretz <kretz@kde.org>

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License version 2 as published by the Free Software Foundation.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.

You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.

*/

#ifndef KDEMM_FACTORY_H
#define KDEMM_FACTORY_H

#include <kurl.h>
#include <kdemm/channel.h>
#include <tqstring.h>
#include <tqstringlist.h>
#include <dcopobject.h>

namespace KDE
{
/**
* \brief The KDE Multimedia classes
*
* In this Namespace you find a few classes to access Multimedia functions like
* playing audio files and simple video playing. Those classes are not dependent
* on any specific framework (like they were in pre KDE4 times) but rather use
* exchangeable backends to do the "dirty" work.
*
* If you want to write a new backend you also find the necessary classes in
* this namespace.
*
* \since 4.0
*/
namespace Multimedia
{
class Backend;
class Player;
class VideoPlayer;

/**
* \brief Factory to access the preferred Backend.
*
* This class is your entry point to KDE Multimedia usage. It provides the
* necessary objects for playing audio and video.
*
* For simple access to just playing an audio file see SimplePlayer.
*
* \remarks
* Extensions to the existing functionality can either be added by using the
* reserved virtual functions in Backend or by adding a new interface e.g.
* BackendV2 and creating a BackendV2 instance when the Backend instance is
* created.
*
* \author Matthias Kretz <kretz@kde.org>
* \since 4.0
*/
class KDE_EXPORT Factory : public TQObject, public DCOPObject
{
Q_OBJECT
public:
/**
* Returns a pointer to the factory.
* Use this function to get an instance of KLibLoader.
*
* @return a pointer to the loader. If no loader exists until now then
* one is created
*/
static Factory * self();

/**
* Create a new Player.
*
* You need to call it like this:
* \code
* Factory::self()->createPlayer();
* \endcode
*
* @return a pointer to the Player the backend provides
*/
Player * createPlayer();

/**
* Create a new VideoPlayer object. The Backend does not have to
* implement this functionality so you have to check that it didn't
* return 0.
*
* @return A new instance to a VideoPlayer from the Backend. Or 0 if
* the Backend does not support the VideoPlayer interface.
*/
VideoPlayer * createVideoPlayer();

/**
* Play the specified sound-file with no further control. Returns
* immediatly.
*
* @return if the file was be succesfully issued, but is not a
* garantie for succes of playing the entire file.
*/
bool playSoundEvent(const KURL & url);

/**
* Creates a new Channel object that you can use for a Player object to
* play to.
*
* \param title A user visible title for the Channel. Most of the time
* you will use the application's name.
*
* \param channeltype \ref availableChannels() returns a list of strings
* where you can choose one to be used. Most of the time you will use
* the "default" channel. But the Backend could also provide special
* purpose channels like one for notifications, one for previews and one
* for media playback.
*
* \param direction Whether it's a Channel::Input or Channel::Output
* that you're requesting.
*
* \returns Returns a Channel object or 0 if your request couldn't be
* fullfilled.
*/
Channel * createChannel( const TQString & title,
const TQString & channeltype = TQString::fromLatin1( "default" ),
Channel::Direction direction = Channel::Output );

/**
* Returns the names of the channels that can be used to play or record,
* depending on the value of \p direction.
*
* \param direction If set to Channel::Output you will get the names of
* all output channels, if set to Channel::Input you get the same for
* the input channels.
*/
TQStringList availableChannels( Channel::Direction direction = Channel::Output ) const;

/**
* Returns the mimetypes that can be played.
*/
TQStringList playableMimeTypes() const;

/**
* Checks whether a certain mimetype is playable.
*/
bool isMimeTypePlayable( const TQString & mimetype ) const;

/**
* Get the name of the Backend. It's the name from the .desktop file.
*/
TQString backendName() const;

/**
* Get the comment of the Backend. It's the comment from the .desktop file.
*/
TQString backendComment() const;

/**
* Get the version of the Backend. It's the version from the .desktop file.
*
* The version is especially interesting if there are several versions
* available for binary incompatible versions of the backend's media
* framework.
*/
TQString backendVersion() const;

/**
* Get the icon (name) of the Backend. It's the icon from the .desktop file.
*/
TQString backendIcon() const;

/**
* Get the website of the Backend. It's the website from the .desktop file.
*/
TQString backendWebsite() const;

signals:
/**
* This signal is emitted when the user changes the backend. You then
* have to free all your references to Player or Channel objects.
*/
void deleteYourObjects();

/**
* After you got a deleteYourObjects() signal the backend is changed
* internally. Then you will receive this signal, and only then should
* you reconstruct all your objects again. This time they will
* internally use the new backend.
*/
void recreateObjects();

protected:
Factory();
~Factory();

private slots:
void objectDestroyed( TQObject * );

private:
static Factory * m_self;
class Private;
Private * d;

K_DCOP
k_dcop:
/**
* \internal
* This is called via DCOP when the user changes the KDEMM Backend.
*/
void kdemmBackendChanged();

};
}} // namespaces

#endif // BACKENDFACTORY_H
// vim: sw=4 ts=4 tw=80 noet

+ 41
- 0
kdemm/mixeriface.h View File

@@ -0,0 +1,41 @@
/* This file is part of the KDE project
Copyright (C) 2004 Matthias Kretz <kretz@kde.org>

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License version 2 as published by the Free Software Foundation.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.

You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.

*/

#ifndef MIXERIFACE_H
#define MIXERIFACE_H

#include <dcopobject.h>
#include <kdelibs_export.h>

class KDE_EXPORT MixerIface : public DCOPObject
{
K_DCOP
k_dcop:
virtual TQString channelName() const = 0;
virtual TQString channelType() const = 0;
virtual bool hasVolumeControl() const = 0;
virtual float volume() const = 0;
virtual bool setVolume( float volume ) = 0;

protected:
MixerIface() : DCOPObject( "MixerIface" ) {}
};

#endif // MIXERIFACE_H
// vim: sw=4 ts=4 noet tw=80

+ 30
- 0
kdemm/mmbackendinfo.desktop View File

@@ -0,0 +1,30 @@
[Desktop Entry]
Encoding=UTF-8
Type=ServiceType
X-KDE-ServiceType=KDEMultimediaBackend
Name=KDE Multimedia Backend

[PropertyDef::X-KDE-MMBackendInfo-Version]
Type=QString

[PropertyDef::X-KDE-MMBackendInfo-Website]
Type=QString

#[PropertyDef::X-KDE-MMBackendInfo-Supports]
#Type=QStringList
#
#[PropertyDef::X-KDE-MMBackendInfo-Depends]
#Type=QStringList
#
#[PropertyDef::X-KDE-MMBackendInfo-License]
#Type=QString
#
#[PropertyDef::X-KDE-MMBackendInfo-Author]
#Type=QString
#
#[PropertyDef::X-KDE-MMBackendInfo-Email]
#Type=QString
#
#[PropertyDef::X-KDE-MMBackendInfo-Name]
#Type=QString
#

+ 53
- 0
kdemm/player.cpp View File

@@ -0,0 +1,53 @@
/* This file is part of the KDE project
Copyright (C) 2004 Matthias Kretz <kretz@kde.org>

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License version 2 as published by the Free Software Foundation.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.

You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.

*/

#include "player.h"

namespace KDE {
namespace Multimedia {
Player::Player( TQObject * parent, const char * name )
: TQObject( parent, name )
, m_state( Player::NoMedia )
{
}

Player::~Player()
{
}

Player::State Player::state() const
{
return m_state;
}

void Player::setState( Player::State newstate )
{
if( m_state != newstate )
{
Player::State oldstate = m_state;
m_state = newstate;
emit stateChanged( newstate, oldstate );
}
}

}} // namespaces

#include "player.moc"

// vim: sw=4 ts=4 noet

+ 259
- 0
kdemm/player.h View File

@@ -0,0 +1,259 @@
/* This file is part of the KDE project
Copyright (C) 2004 Matthias Kretz <kretz@kde.org>

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License version 2 as published by the Free Software Foundation.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.

You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.

*/

#ifndef PLAYOBJECT_H
#define PLAYOBJECT_H

#include <kdelibs_export.h>
#include <tqobject.h>

class KURL;

namespace KDE
{
namespace Multimedia
{
class Channel;
/**
* \short Interface for accessing media playback functions
*
* \author Matthias Kretz <kretz@kde.org>
* \since 4.0
*/
class Player : public QObject
{
Q_OBJECT
public:
/**
* The state the playobject is in at the moment
*/
enum State
{
/**
* The load method wasn't called or didn't succeed. If the
* object is in this state the next thing you have to do is to
* call load.
*/
NoMedia,
/**
* After calling load it might take a while before the Player is
* ready to play(). Normally this doesn't happen for local
* files, but can happen for remote files where the asynchronous
* mimetype detection can take a while.
*/
Loading,
/**
* The Player has a valid media file loaded and is ready for
* playing.
*/
Stopped,
/**
* The Player is playing a media file.
*/
Playing,
/**
* The Player is waiting for data to be able to continue
* playing.
*/
Buffering,
/**
* The Player is paused currently.
*/
Paused
};

virtual ~Player();

/**
* Set the output device the Player should use.
*
* @return Returns \p true on success. If it returns \p false the
* output device wasn't changed. This could happen if you pass a
* Channel with Channel::direction() == Channel::Input.
*/
virtual bool setOutputChannel( Channel * device ) = 0;

/**
* Get the current state.
*/
virtual State state() const;

/**
* Check whether the Player supports to control the volume.
*
* @returns Return \p true if the Player can change its volume.
*/
virtual bool hasVolumeControl() const = 0;

/**
* Get the current volume.
*
* @returns the current volume
*/
virtual float volume() const = 0;

/**
* Get the total time (in milliseconds) of the file currently being played.
*/
virtual long totalTime() const = 0;

/**
* Get the remaining time (in milliseconds) of the file currently being played.
*/
virtual long remainingTime() const = 0;

/**
* Get the current time (in milliseconds) of the file currently being played.
*/
virtual long currentTime() const = 0;

/**
* If the current media may be seeked returns true.
*
* @returns whether the current media may be seeked.
*/
virtual bool seekable() const = 0;

/**
* Return the time interval in milliseconds between two ticks.
*/
virtual long tickInterval() const = 0;

public slots:
/**
* Load a media file. If another media is currently loaded it is
* stopped and unloaded.
*
* @param url The location of the media file
*
* @returns If the call was successfull (the media file was found
* and can be read and decoded) returns \p true
*/
virtual bool load( const KURL & url ) = 0;

/**
* Play the media file.
*/
virtual bool play() = 0;