[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    Re: [Amarok] MySQL database configuration support. Thanks to Jo
From:       Mark Kretschmann <kretschmann () kde ! org>
Date:       2009-08-30 19:54:42
Message-ID: e93871060908301254i6d9302aeq2b0f3f2c08d52f18 () mail ! gmail ! com
[Download RAW message or body]

I'm sorry, but this patch seems badly broken. It's using config
options that don't exist, and mixes KConfigXT with classic KConfig. I
can't really see how that's supposed to work.

The whole "MySQL" group is missing in amarokconfig.kcfg.

Users with debug builds of KDElibs are getting an instant crash when
opening the dialog:

amarok(4185)/kdecore (KConfigDialogManager)
KConfigDialogManager::parseChildren: A widget named '
"kcfg_UseInternalDB" ' was found but there is no setting named '
"UseInternalDB" '


Here's some documentation on KConfigXT:
http://developer.kde.org/documentation/tutorials/kconfigxt/kconfigxt.html



On Sun, Aug 30, 2009 at 3:24 AM, Seb Ruiz<ruiz@kde.org> wrote:
> commit 698fd3c2b47f876b5ef053d0028d594ca8e34df9
> Author:     Seb Ruiz <ruiz@kde.org>
> AuthorDate: Sun Aug 30 10:44:52 2009 +1000
> Commit:     Seb Ruiz <ruiz@kde.org>
> CommitDate: Sun Aug 30 10:44:52 2009 +1000
> 
> MySQL database configuration support. Thanks to John Atkinson for the patch!
> CCMAIL: john@fauxnetic.co.uk
> 
> diff --git a/ChangeLog b/ChangeLog
> index 5a268f6..cc9efe6 100644
> --- a/ChangeLog
> +++ b/ChangeLog
> @@ -62,8 +62,7 @@ VERSION 2.2-beta1
> The video can be appended to the playlist, and rendered within the applet.
> * Photo applet to show images from Flickr, with customizable animations.
> * Customizable user interface using dock widgets.
> -    * Support for external MySQL database. See
> -      http://amarok.kde.org/wiki/MySQL_Server.
> +    * Support for external MySQL database.
> * GHNS integration for downloading and installing Context applets.
> * Support for Context applets to be written in QtScript.
> * Custom Dynamic Playlists using Last.fm.
> diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
> index 323fe0d..cab1d28 100644
> --- a/src/CMakeLists.txt
> +++ b/src/CMakeLists.txt
> @@ -187,6 +187,7 @@ set(libconfigdialog_SRCS
> configdialog/dialogs/OsdConfig.cpp
> configdialog/dialogs/PlaybackConfig.cpp
> configdialog/dialogs/ServiceConfig.cpp
> +    configdialog/dialogs/DatabaseConfig.cpp
> )
> 
> kde4_add_ui_files(libconfigdialog_SRCS
> @@ -194,6 +195,7 @@ kde4_add_ui_files(libconfigdialog_SRCS
> configdialog/dialogs/GeneralConfig.ui
> configdialog/dialogs/OsdConfig.ui
> configdialog/dialogs/PlaybackConfig.ui
> +    configdialog/dialogs/DatabaseConfig.ui
> )
> 
> set(libbrowserframework_SRCS
> diff --git a/src/configdialog/ConfigDialog.cpp b/src/configdialog/ConfigDialog.cpp
> index c18239d..b53ae4f 100644
> --- a/src/configdialog/ConfigDialog.cpp
> +++ b/src/configdialog/ConfigDialog.cpp
> @@ -27,6 +27,7 @@
> #include "OsdConfig.h"
> #include "PlaybackConfig.h"
> #include "ServiceConfig.h"
> +#include "DatabaseConfig.h"
> 
> #include <KLocale>
> 
> @@ -47,6 +48,7 @@ Amarok2ConfigDialog::Amarok2ConfigDialog( QWidget *parent, const \
> char* name, KCo ConfigDialogBase* services    = new ServiceConfig( this );
> ConfigDialogBase* playback    = new PlaybackConfig( this );
> ConfigDialogBase* osd         = new OsdConfig( this );
> +    ConfigDialogBase* database    = new DatabaseConfig( this );
> 
> connect( general, SIGNAL( lockLayout( bool ) ), The::mainWindow(), SLOT ( \
> setLayoutLocked( bool ) ) ); 
> @@ -57,6 +59,7 @@ Amarok2ConfigDialog::Amarok2ConfigDialog( QWidget *parent, const \
> char* name, KCo addPage( services,    i18n( "Internet Services" ), \
> "services-amarok", i18n( "Configure Services" ) ); addPage( playback,    i18n( \
> "Playback" ), "preferences-media-playback-amarok", i18n( "Configure Playback" ) ); \
> addPage( osd,         i18n( "On Screen Display" ), "preferences-indicator-amarok", \
> i18n( "Configure On-Screen-Display" ) ); +    addPage( database,    i18n( \
> "Database" ), "preferences-database-amarok", i18n( "Configure Database" ) ); //    \
> addPage( mediadevice, i18n( "Media Devices" ), \
> "preferences-multimedia-player-amarok", i18n( "Configure Portable Player Support" ) \
> ); 
> setButtons( Help | Ok | Apply | Cancel );
> diff --git a/src/configdialog/dialogs/DatabaseConfig.cpp \
> b/src/configdialog/dialogs/DatabaseConfig.cpp new file mode 100644
> index 0000000..8088d8e
> --- /dev/null
> +++ b/src/configdialog/dialogs/DatabaseConfig.cpp
> @@ -0,0 +1,159 @@
> +/****************************************************************************************
>  + * Copyright (c) 2009 John Atkinson <john@fauxnetic.co.uk>                        \
> * + *                                                                               \
> * + * This program is free software; you can redistribute it and/or modify it under \
> * + * the terms of the GNU General Public License as published by the Free Software \
> * + * Foundation; either version 2 of the License, or (at your option) any later    \
> * + * version.                                                                      \
> * + *                                                                               \
> * + * This program 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 General Pulic License for \
> more details.              * + *                                                    \
> * + * You should have received a copy of the GNU General Public License along with  \
> * + * this program.  If not, see <http://www.gnu.org/licenses/>.                    \
> * + ****************************************************************************************/
>  +
> +#include "DatabaseConfig.h"
> +
> +#include "Amarok.h"
> +#include "Debug.h"
> +
> +#include <KCMultiDialog>
> +
> +
> +DatabaseConfig::DatabaseConfig( QWidget* parent )
> +    : ConfigDialogBase( parent )
> +{
> +    setupUi( this );
> +    readConfiguration();
> +
> +    connect( kcfg_UseInternalDB, SIGNAL( stateChanged(int) ), SLOT( \
> toggleExternalConfigAvailable(int) ) ); +
> +    connect( kcfg_DBName,   SIGNAL( editingFinished() ), SLOT( updateSQLQuery() ) \
> ); +    connect( kcfg_Username, SIGNAL( editingFinished() ), SLOT( updateSQLQuery() \
> ) ); +    connect( kcfg_Server,   SIGNAL( editingFinished() ), SLOT( \
> updateSQLQuery() ) ); +
> +}
> +
> +DatabaseConfig::~DatabaseConfig()
> +{}
> +
> +
> +///////////////////////////////////////////////////////////////
> +// REIMPLEMENTED METHODS from ConfigDialogBase
> +///////////////////////////////////////////////////////////////
> +
> +bool
> +DatabaseConfig::hasChanged()
> +{
> +    return false;
> +}
> +
> +bool
> +DatabaseConfig::isDefault()
> +{
> +    return false;
> +}
> +
> +void
> +DatabaseConfig::updateSettings()
> +{
> +    writeConfiguration();
> +}
> +
> +
> +///////////////////////////////////////////////////////////////
> +// PRIVATE METHODS
> +///////////////////////////////////////////////////////////////
> +
> +void
> +DatabaseConfig::readConfiguration()
> +{
> +    KConfigGroup config = Amarok::config( "MySQL" );
> +
> +    kcfg_UseInternalDB->setChecked( !config.readEntry( "UseServer", false ) );
> +
> +    kcfg_Server->setText( config.readEntry( "Host", "localhost" ).toUtf8() );
> +    kcfg_Port->setValue( config.readEntry( "Port", "3306" ).toInt() );
> +    kcfg_DBName->setText( config.readEntry( "Database", "amarokdb" ).toUtf8() );
> +
> +    kcfg_Username->setText( config.readEntry( "User", "amarokuser" ).toUtf8() );
> +    kcfg_Password->setText( config.readEntry( "Password", "" ).toUtf8() );
> +
> +
> +    toggleExternalConfigAvailable(kcfg_UseInternalDB->checkState());
> +    updateSQLQuery();
> +}
> +
> +void
> +DatabaseConfig::writeConfiguration()
> +{
> +    KConfigGroup config = Amarok::config( "MySQL" );
> +
> +    bool useExternal = (kcfg_UseInternalDB->checkState() != Qt::Checked);
> +
> +    config.writeEntry( "UseServer", useExternal );
> +
> +    if(useExternal)
> +    {
> +        config.writeEntry( "Host",      kcfg_Server->text() );
> +        config.writeEntry( "Port",      kcfg_Port->value() );
> +        config.writeEntry( "Database",  kcfg_DBName->text() );
> +        config.writeEntry( "User",      kcfg_Username->text() );
> +        config.writeEntry( "Password",  kcfg_Password->text() );
> +    }
> +}
> +
> +
> +void
> +DatabaseConfig::toggleExternalConfigAvailable( int checkBoxState ) //SLOT
> +{
> +    bool enableExternalConfig = (checkBoxState != Qt::Checked);
> +
> +    kcfg_DatabaseEngine->setEnabled( enableExternalConfig );
> +    group_Connection->setVisible( enableExternalConfig );
> +
> +}
> +
> +void
> +DatabaseConfig::updateSQLQuery() //SLOT
> +{
> +    if(isSQLInfoPresent())
> +    {
> +        // Query template:
> +        // GRANT ALL ON amarokdb.* TO 'amarokuser'@'localhost' IDENTIFIED BY \
> 'mypassword'; FLUSH PRIVILEGES; +
> +        // Don't print the actual password!
> +        QString examplePassword = i18nc( "A default password for insertion into an \
> example SQL command (so as not to print the real one). To be manually replaced by \
> the user.", +                                         "password" );
> +
> +        text_SQL->setPlainText( "GRANT ALL ON " + kcfg_DBName->text() + ".* " +
> +                                "TO '" + kcfg_Username->text() + "'@'" + \
> kcfg_Server->text() + "' " + +                                "IDENTIFIED BY '" + \
> examplePassword + "';\n" + +                                "FLUSH PRIVILEGES;"
> +                                );
> +    }
> +    else
> +    {
> +        text_SQL->setPlainText("");
> +    }
> +
> +}
> +
> +
> +bool
> +DatabaseConfig::isSQLInfoPresent()
> +{
> +    if( kcfg_DBName->text().isEmpty() || kcfg_Username->text().isEmpty() || \
> kcfg_Server->text().isEmpty() ) +    {
> +        return false;
> +    }
> +
> +    return true;
> +}
> +
> +
> +#include "DatabaseConfig.moc"
> +
> +
> diff --git a/src/configdialog/dialogs/DatabaseConfig.h \
> b/src/configdialog/dialogs/DatabaseConfig.h new file mode 100644
> index 0000000..d7e1b1d
> --- /dev/null
> +++ b/src/configdialog/dialogs/DatabaseConfig.h
> @@ -0,0 +1,51 @@
> +/****************************************************************************************
>  + * Copyright (c) 2009 John Atkinson <john@fauxnetic.co.uk>                        \
> * + *                                                                               \
> * + * This program is free software; you can redistribute it and/or modify it under \
> * + * the terms of the GNU General Public License as published by the Free Software \
> * + * Foundation; either version 2 of the License, or (at your option) any later    \
> * + * version.                                                                      \
> * + *                                                                               \
> * + * This program 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 General Pulic License for \
> more details.              * + *                                                    \
> * + * You should have received a copy of the GNU General Public License along with  \
> * + * this program.  If not, see <http://www.gnu.org/licenses/>.                    \
> * + ****************************************************************************************/
>  +
> +#ifndef DATABASECONFIG_H
> +#define DATABASECONFIG_H
> +
> +#include "ui_DatabaseConfig.h"
> +#include "ConfigDialogBase.h"
> +
> +
> +class DatabaseConfig : public ConfigDialogBase, public Ui_DatabaseConfig
> +{
> +    Q_OBJECT
> +
> +    public:
> +        DatabaseConfig( QWidget* parent );
> +        virtual ~DatabaseConfig();
> +
> +        virtual bool hasChanged();
> +        virtual bool isDefault();
> +        virtual void updateSettings();
> +
> +    protected:
> +        void readConfiguration();
> +        void writeConfiguration();
> +
> +    private Q_SLOTS:
> +        void toggleExternalConfigAvailable( int checkBoxState );
> +        void updateSQLQuery();
> +
> +    private:
> +        bool isSQLInfoPresent();
> +};
> +
> +
> +#endif
> +
> +
> diff --git a/src/configdialog/dialogs/DatabaseConfig.ui \
> b/src/configdialog/dialogs/DatabaseConfig.ui new file mode 100644
> index 0000000..f874364
> --- /dev/null
> +++ b/src/configdialog/dialogs/DatabaseConfig.ui
> @@ -0,0 +1,282 @@
> +<?xml version="1.0" encoding="UTF-8"?>
> +<ui version="4.0">
> + <class>DatabaseConfig</class>
> + <widget class="QWidget" name="DatabaseConfig">
> +  <property name="geometry">
> +   <rect>
> +    <x>0</x>
> +    <y>0</y>
> +    <width>440</width>
> +    <height>426</height>
> +   </rect>
> +  </property>
> +  <layout class="QVBoxLayout" name="verticalLayout_2">
> +   <item>
> +    <widget class="QCheckBox" name="kcfg_UseInternalDB">
> +     <property name="text">
> +      <string>Use &amp;internal database (default)</string>
> +     </property>
> +    </widget>
> +   </item>
> +   <item>
> +    <layout class="QGridLayout" name="gridLayout_4">
> +     <item row="0" column="1">
> +      <widget class="QComboBox" name="kcfg_DatabaseEngine">
> +       <property name="sizePolicy">
> +        <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
> +         <horstretch>0</horstretch>
> +         <verstretch>0</verstretch>
> +        </sizepolicy>
> +       </property>
> +       <item>
> +        <property name="text">
> +         <string>MySQL</string>
> +        </property>
> +       </item>
> +      </widget>
> +     </item>
> +     <item row="0" column="0">
> +      <widget class="QLabel" name="label_DatabaseEngine">
> +       <property name="text">
> +        <string>&amp;External database engine:</string>
> +       </property>
> +       <property name="buddy">
> +        <cstring>kcfg_DatabaseEngine</cstring>
> +       </property>
> +      </widget>
> +     </item>
> +    </layout>
> +   </item>
> +   <item>
> +    <widget class="QGroupBox" name="group_Connection">
> +     <property name="title">
> +      <string>Connection Settings</string>
> +     </property>
> +     <layout class="QVBoxLayout" name="verticalLayout_3">
> +      <item>
> +       <layout class="QGridLayout" name="gridLayout_3">
> +        <item row="0" column="0">
> +         <widget class="QLabel" name="label_Server">
> +          <property name="text">
> +           <string>&amp;Server:</string>
> +          </property>
> +          <property name="textFormat">
> +           <enum>Qt::AutoText</enum>
> +          </property>
> +          <property name="alignment">
> +           <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
> +          </property>
> +          <property name="buddy">
> +           <cstring>kcfg_Server</cstring>
> +          </property>
> +         </widget>
> +        </item>
> +        <item row="0" column="1" colspan="3">
> +         <widget class="QLineEdit" name="kcfg_Server">
> +          <property name="text">
> +           <string notr="true"/>
> +          </property>
> +         </widget>
> +        </item>
> +        <item row="0" column="4">
> +         <widget class="QLabel" name="label_Port">
> +          <property name="text">
> +           <string>P&amp;ort:</string>
> +          </property>
> +          <property name="textFormat">
> +           <enum>Qt::AutoText</enum>
> +          </property>
> +          <property name="alignment">
> +           <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
> +          </property>
> +          <property name="buddy">
> +           <cstring>kcfg_Port</cstring>
> +          </property>
> +         </widget>
> +        </item>
> +        <item row="0" column="5">
> +         <widget class="QSpinBox" name="kcfg_Port">
> +          <property name="maximum">
> +           <number>65535</number>
> +          </property>
> +         </widget>
> +        </item>
> +        <item row="1" column="0">
> +         <widget class="QLabel" name="label_Username">
> +          <property name="text">
> +           <string>&amp;Username:</string>
> +          </property>
> +          <property name="textFormat">
> +           <enum>Qt::AutoText</enum>
> +          </property>
> +          <property name="alignment">
> +           <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
> +          </property>
> +          <property name="buddy">
> +           <cstring>kcfg_Username</cstring>
> +          </property>
> +         </widget>
> +        </item>
> +        <item row="2" column="1" colspan="5">
> +         <widget class="QLineEdit" name="kcfg_Password">
> +          <property name="inputMask">
> +           <string notr="true"/>
> +          </property>
> +          <property name="text">
> +           <string notr="true"/>
> +          </property>
> +          <property name="echoMode">
> +           <enum>QLineEdit::Password</enum>
> +          </property>
> +         </widget>
> +        </item>
> +        <item row="2" column="0">
> +         <widget class="QLabel" name="label_Password">
> +          <property name="text">
> +           <string>&amp;Password:</string>
> +          </property>
> +          <property name="textFormat">
> +           <enum>Qt::AutoText</enum>
> +          </property>
> +          <property name="alignment">
> +           <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
> +          </property>
> +          <property name="buddy">
> +           <cstring>kcfg_Password</cstring>
> +          </property>
> +         </widget>
> +        </item>
> +        <item row="1" column="1" colspan="5">
> +         <widget class="QLineEdit" name="kcfg_Username">
> +          <property name="text">
> +           <string notr="true"/>
> +          </property>
> +         </widget>
> +        </item>
> +        <item row="3" column="0">
> +         <widget class="QLabel" name="label_DBName">
> +          <property name="text">
> +           <string>&amp;Database:</string>
> +          </property>
> +          <property name="textFormat">
> +           <enum>Qt::AutoText</enum>
> +          </property>
> +          <property name="alignment">
> +           <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
> +          </property>
> +          <property name="buddy">
> +           <cstring>kcfg_DBName</cstring>
> +          </property>
> +         </widget>
> +        </item>
> +        <item row="3" column="1" colspan="5">
> +         <widget class="QLineEdit" name="kcfg_DBName">
> +          <property name="text">
> +           <string notr="true"/>
> +          </property>
> +         </widget>
> +        </item>
> +       </layout>
> +      </item>
> +      <item>
> +       <widget class="QFrame" name="frame_info">
> +        <property name="frameShape">
> +         <enum>QFrame::StyledPanel</enum>
> +        </property>
> +        <property name="frameShadow">
> +         <enum>QFrame::Raised</enum>
> +        </property>
> +        <layout class="QVBoxLayout" name="verticalLayout">
> +         <item>
> +          <widget class="QLabel" name="label_Info">
> +           <property name="font">
> +            <font>
> +             <pointsize>8</pointsize>
> +            </font>
> +           </property>
> +           <property name="text">
> +            <string>Amarok expects the above database and user account to already \
> exist. This user also requires full access to the database.</string> +           \
> </property> +           <property name="alignment">
> +            <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
> +           </property>
> +           <property name="wordWrap">
> +            <bool>true</bool>
> +           </property>
> +          </widget>
> +         </item>
> +         <item>
> +          <widget class="QLabel" name="label_SQL">
> +           <property name="font">
> +            <font>
> +             <pointsize>8</pointsize>
> +            </font>
> +           </property>
> +           <property name="text">
> +            <string>Access rights can be assigned with the following S&amp;QL \
> commands (after replacing the password with the correct one):</string> +           \
> </property> +           <property name="wordWrap">
> +            <bool>true</bool>
> +           </property>
> +           <property name="buddy">
> +            <cstring>text_SQL</cstring>
> +           </property>
> +          </widget>
> +         </item>
> +         <item>
> +          <widget class="QPlainTextEdit" name="text_SQL">
> +           <property name="sizePolicy">
> +            <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
> +             <horstretch>0</horstretch>
> +             <verstretch>0</verstretch>
> +            </sizepolicy>
> +           </property>
> +           <property name="maximumSize">
> +            <size>
> +             <width>16777215</width>
> +             <height>50</height>
> +            </size>
> +           </property>
> +           <property name="font">
> +            <font>
> +             <pointsize>6</pointsize>
> +            </font>
> +           </property>
> +           <property name="cursor" stdset="0">
> +            <cursorShape>IBeamCursor</cursorShape>
> +           </property>
> +           <property name="acceptDrops">
> +            <bool>false</bool>
> +           </property>
> +           <property name="readOnly">
> +            <bool>true</bool>
> +           </property>
> +           <property name="plainText">
> +            <string notr="true"/>
> +           </property>
> +          </widget>
> +         </item>
> +        </layout>
> +       </widget>
> +      </item>
> +     </layout>
> +    </widget>
> +   </item>
> +   <item>
> +    <spacer name="verticalSpacer">
> +     <property name="orientation">
> +      <enum>Qt::Vertical</enum>
> +     </property>
> +     <property name="sizeHint" stdset="0">
> +      <size>
> +       <width>20</width>
> +       <height>40</height>
> +      </size>
> +     </property>
> +    </spacer>
> +   </item>
> +  </layout>
> + </widget>
> + <resources/>
> + <connections/>
> +</ui>
> 
> 
> 


-- 
Mark Kretschmann
Amarok Developer
www.kde.org - amarok.kde.org


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic