From 8eae0f1e909e8ef7ac4ff3ac99af0c11c33aeeba Mon Sep 17 00:00:00 2001 From: Rodney Dawes Date: Fri, 13 May 2022 16:41:16 -0400 Subject: [PATCH 01/13] Remove MImPluginSettingsInfo and AbstractPluginSetting --- CMakeLists.txt | 2 - common/maliit/settingdata.h | 20 --- connection/dbuscustomarguments.cpp | 68 ------- connection/dbuscustomarguments.h | 10 -- connection/dbusinputcontextconnection.cpp | 18 -- connection/dbusinputcontextconnection.h | 2 - connection/dbusserverconnection.cpp | 17 -- connection/dbusserverconnection.h | 2 - connection/mimserverconnection.cpp | 5 - connection/mimserverconnection.h | 11 -- connection/minputcontextconnection.cpp | 13 -- connection/minputcontextconnection.h | 12 -- .../minputmethodcontext1interface.xml | 4 - .../minputmethodserver1interface.xml | 3 - .../cxx/helloworld/helloworldinputmethod.cpp | 18 +- .../cxx/helloworld/helloworldinputmethod.h | 3 - maliit-glib/maliitbus.c | 16 -- maliit-glib/maliitsettingsmanager.c | 10 +- src/maliit/plugins/abstractinputmethodhost.h | 22 --- src/maliit/plugins/abstractpluginsetting.h | 69 -------- src/maliit/standaloneinputmethod.cpp | 4 - src/maliit/standaloneinputmethodhost.cpp | 10 +- src/maliit/standaloneinputmethodhost.h | 4 - src/mimpluginmanager.cpp | 166 +----------------- src/mimpluginmanager.h | 14 -- src/mimpluginmanager_p.h | 25 --- src/minputmethodhost.cpp | 8 - src/minputmethodhost.h | 6 - src/msharedattributeextensionmanager.cpp | 11 -- src/msharedattributeextensionmanager.h | 7 - tests/dummyimplugin3/dummyinputmethod3.cpp | 11 -- tests/dummyimplugin3/dummyinputmethod3.h | 6 - .../ft_mimpluginmanager.cpp | 89 ---------- .../ft_mimpluginmanager/ft_mimpluginmanager.h | 1 - .../mockmaliitserver.c | 16 -- .../mockmaliitserver.h | 1 - .../ut_maliit_glib_settings.c | 39 ---- .../ut_mimpluginmanager.cpp | 101 +---------- .../ut_mimpluginmanager/ut_mimpluginmanager.h | 3 - .../ut_mimpluginmanagerconfig.cpp | 12 -- .../ut_mimpluginmanagerconfig.h | 2 - tests/utils/gui-utils.cpp | 25 --- tests/utils/gui-utils.h | 32 ---- 43 files changed, 5 insertions(+), 913 deletions(-) delete mode 100644 src/maliit/plugins/abstractpluginsetting.h delete mode 100644 tests/utils/gui-utils.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 7d4d1f26..9b5fc96b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -114,7 +114,6 @@ set(PLUGINS_SOURCES src/maliit/plugins/abstractinputmethod.h src/maliit/plugins/abstractinputmethodhost.cpp src/maliit/plugins/abstractinputmethodhost.h - src/maliit/plugins/abstractpluginsetting.h src/maliit/plugins/attributeextension.cpp src/maliit/plugins/attributeextension.h src/maliit/plugins/attributeextension_p.h @@ -494,7 +493,6 @@ if(enable-tests) add_library(test-utils STATIC tests/utils/core-utils.cpp tests/utils/core-utils.h - tests/utils/gui-utils.cpp tests/utils/gui-utils.h) target_link_libraries(test-utils PUBLIC Qt5::Core Qt5::Gui Qt5::Test maliit-connection) target_include_directories(test-utils INTERFACE tests/utils) diff --git a/common/maliit/settingdata.h b/common/maliit/settingdata.h index 343f9705..4fbc6daf 100644 --- a/common/maliit/settingdata.h +++ b/common/maliit/settingdata.h @@ -39,31 +39,11 @@ struct MImPluginSettingsEntry }; -/*! - * \brief Settings for a Maliit input method plugin - */ -struct MImPluginSettingsInfo -{ - //! The language used for human-readable descriptions - QString description_language; - //! Internal plugin name; "server" for global configuration entries - QString plugin_name; - //! Human-readable plugin description - QString plugin_description; - //! Attribute extension id; multiple MImPluginSettingsInfo instances might share the same extension id - int extension_id; - //! List of configuration entries for this plugin - QList entries; -}; - - /*! * \brief Validate the value for a plugin setting entry */ bool validateSettingValue(Maliit::SettingEntryType type, const QVariantMap attributes, const QVariant &value); Q_DECLARE_METATYPE(MImPluginSettingsEntry) -Q_DECLARE_METATYPE(MImPluginSettingsInfo) -Q_DECLARE_METATYPE(QList) #endif diff --git a/connection/dbuscustomarguments.cpp b/connection/dbuscustomarguments.cpp index c0e99db7..b34680f7 100644 --- a/connection/dbuscustomarguments.cpp +++ b/connection/dbuscustomarguments.cpp @@ -18,74 +18,6 @@ QT_BEGIN_NAMESPACE -QDBusArgument &operator<<(QDBusArgument &argument, const MImPluginSettingsEntry &entry) -{ - argument.beginStructure(); - argument << entry.description; - argument << entry.extension_key; - argument << static_cast(entry.type); - // DBus does not have an "invalid variant" value, so we encode the validity as - // a separate boolean field - argument << entry.value.isValid(); - if (entry.value.isValid()) - argument << QDBusVariant(entry.value); - else - argument << QDBusVariant(QVariant(0)); - argument << entry.attributes; - argument.endStructure(); - - return argument; -} - -const QDBusArgument &operator>>(const QDBusArgument &argument, MImPluginSettingsEntry &entry) -{ - bool valid_value; - int type; - - argument.beginStructure(); - argument >> entry.description; - argument >> entry.extension_key; - argument >> type; - // see comment in operator<< - argument >> valid_value; - argument >> entry.value; - if (!valid_value) - entry.value = QVariant(); - - argument >> entry.attributes; - argument.endStructure(); - - entry.type = static_cast(type); - - return argument; -} - -QDBusArgument &operator<<(QDBusArgument &argument, const MImPluginSettingsInfo &info) -{ - argument.beginStructure(); - argument << info.description_language; - argument << info.plugin_name; - argument << info.plugin_description; - argument << info.extension_id; - argument << info.entries; - argument.endStructure(); - - return argument; -} - -const QDBusArgument &operator>>(const QDBusArgument &argument, MImPluginSettingsInfo &info) -{ - argument.beginStructure(); - argument >> info.description_language; - argument >> info.plugin_name; - argument >> info.plugin_description; - argument >> info.extension_id; - argument >> info.entries; - argument.endStructure(); - - return argument; -} - QDBusArgument &operator<<(QDBusArgument &arg, const Maliit::PreeditTextFormat &format) { arg.beginStructure(); diff --git a/connection/dbuscustomarguments.h b/connection/dbuscustomarguments.h index 90096c99..51010746 100644 --- a/connection/dbuscustomarguments.h +++ b/connection/dbuscustomarguments.h @@ -13,9 +13,6 @@ #ifndef DBUSCUSTOMARGUMENTS_H #define DBUSCUSTOMARGUMENTS_H -class MImPluginSettingsEntry; -class MImPluginSettingsInfo; - #include #include @@ -23,13 +20,6 @@ class MImPluginSettingsInfo; QT_BEGIN_NAMESPACE class QDBusArgument; class QVariant; -// MImPluginSettingsEntry marshalling -QDBusArgument &operator<<(QDBusArgument &argument, const MImPluginSettingsEntry &entry); -const QDBusArgument &operator>>(const QDBusArgument &argument, MImPluginSettingsEntry &entry); - -// MImPluginSettingsInfo marshalling -QDBusArgument &operator<<(QDBusArgument &argument, const MImPluginSettingsInfo &info); -const QDBusArgument &operator>>(const QDBusArgument &argument, MImPluginSettingsInfo &info); QDBusArgument &operator<<(QDBusArgument &arg, const Maliit::PreeditTextFormat &format); const QDBusArgument &operator>>(const QDBusArgument &arg, Maliit::PreeditTextFormat &format); diff --git a/connection/dbusinputcontextconnection.cpp b/connection/dbusinputcontextconnection.cpp index 81826489..f7bc496e 100644 --- a/connection/dbusinputcontextconnection.cpp +++ b/connection/dbusinputcontextconnection.cpp @@ -48,9 +48,6 @@ DBusInputContextConnection::DBusInputContextConnection(const QSharedPointer(); - qDBusRegisterMetaType(); - qDBusRegisterMetaType >(); qDBusRegisterMetaType(); qDBusRegisterMetaType >(); @@ -290,16 +287,6 @@ DBusInputContextConnection::notifyExtendedAttributeChanged(const QList &cli } } -void -DBusInputContextConnection::pluginSettingsLoaded(int clientId, const QList &info) -{ - ComMeegoInputmethodInputcontext1Interface *proxy = mProxys.value(clientId); - if (proxy) { - proxy->pluginSettingsLoaded(info); - } -} - - unsigned int DBusInputContextConnection::connectionNumber() { @@ -375,8 +362,3 @@ void DBusInputContextConnection::setExtendedAttribute(int id, const QString &tar { MInputContextConnection::setExtendedAttribute(connectionNumber(), id, target, targetItem, attribute, value.variant()); } - -void DBusInputContextConnection::loadPluginSettings(const QString &descriptionLanguage) -{ - MInputContextConnection::loadPluginSettings(connectionNumber(), descriptionLanguage); -} diff --git a/connection/dbusinputcontextconnection.h b/connection/dbusinputcontextconnection.h index d5b6faca..115e74a5 100644 --- a/connection/dbusinputcontextconnection.h +++ b/connection/dbusinputcontextconnection.h @@ -65,7 +65,6 @@ class DBusInputContextConnection : public MInputContextConnection, const QString &targetItem, const QString &attribute, const QVariant &value); - virtual void pluginSettingsLoaded(int clientId, const QList &info); //! \reimp_end void activateContext(); @@ -82,7 +81,6 @@ class DBusInputContextConnection : public MInputContextConnection, void registerAttributeExtension(int id, const QString &fileName); void unregisterAttributeExtension(int id); void setExtendedAttribute(int id, const QString &target, const QString &targetItem, const QString &attribute, const QDBusVariant &value); - void loadPluginSettings(const QString &descriptionLanguage); private Q_SLOTS: void newConnection(const QDBusConnection &connection); diff --git a/connection/dbusserverconnection.cpp b/connection/dbusserverconnection.cpp index a899cb06..1991c149 100644 --- a/connection/dbusserverconnection.cpp +++ b/connection/dbusserverconnection.cpp @@ -41,9 +41,6 @@ DBusServerConnection::DBusServerConnection(const QSharedPointer(); - qDBusRegisterMetaType(); - qDBusRegisterMetaType >(); qDBusRegisterMetaType(); qDBusRegisterMetaType >(); @@ -248,20 +245,6 @@ void DBusServerConnection::setExtendedAttribute(int id, const QString &target, c mProxy->setExtendedAttribute(id, target, targetItem, attribute, QDBusVariant(value)); } -void DBusServerConnection::loadPluginSettings(const QString &descriptionLanguage) -{ - if (!mProxy) - return; - - mProxy->loadPluginSettings(descriptionLanguage); -} - - -void DBusServerConnection::pluginSettingsLoaded(const QList &info) -{ - pluginSettingsReceived(info); -} - void DBusServerConnection::keyEvent(int type, int key, int modifiers, const QString &text, bool autoRepeat, int count, uchar requestType) { diff --git a/connection/dbusserverconnection.h b/connection/dbusserverconnection.h index 3d252978..61b4ed88 100644 --- a/connection/dbusserverconnection.h +++ b/connection/dbusserverconnection.h @@ -52,7 +52,6 @@ class DBusServerConnection : public MImServerConnection virtual void unregisterAttributeExtension(int id); virtual void setExtendedAttribute(int id, const QString &target, const QString &targetItem, const QString &attribute, const QVariant &value); - virtual void loadPluginSettings(const QString &descriptionLanguage); //! reimpl end //! forwarding methods for InputContextAdaptor @@ -65,7 +64,6 @@ class DBusServerConnection : public MImServerConnection const QString &targetItem, const QString &attribute, const QDBusVariant &value); - void pluginSettingsLoaded(const QList &info); bool preeditRectangle(int &x, int &y, int &width, int &height) const; bool selection(QString &selection) const; diff --git a/connection/mimserverconnection.cpp b/connection/mimserverconnection.cpp index 445dcb82..ec00cf42 100644 --- a/connection/mimserverconnection.cpp +++ b/connection/mimserverconnection.cpp @@ -111,8 +111,3 @@ void MImServerConnection::setExtendedAttribute(int id, const QString &target, co Q_UNUSED(attribute); Q_UNUSED(value); } - -void MImServerConnection::loadPluginSettings(const QString &descriptionLanguage) -{ - Q_UNUSED(descriptionLanguage); -} diff --git a/connection/mimserverconnection.h b/connection/mimserverconnection.h index 14c62c67..abf54184 100644 --- a/connection/mimserverconnection.h +++ b/connection/mimserverconnection.h @@ -19,7 +19,6 @@ #include class MImServerConnectionPrivate; -class MImPluginSettingsInfo; class MImServerConnection : public QObject { @@ -50,7 +49,6 @@ class MImServerConnection : public QObject virtual void unregisterAttributeExtension(int id); virtual void setExtendedAttribute(int id, const QString &target, const QString &targetItem, const QString &attribute, const QVariant &value); - virtual void loadPluginSettings(const QString &descriptionLanguage); public: /*! \brief Notifies about connection to server being established. @@ -183,15 +181,6 @@ class MImServerConnection : public QObject const QString &attribute, const QVariant &value); - /*! - * \brief Updates the list of server settings known to the application. - * \param info list of server and plugin settings - * - * Sent in response to \a loadPluginSettings(). Might be sent spontaneously by - * the server in response to external events (plugin loaded/unloaded, ...). - */ - Q_SIGNAL void pluginSettingsReceived(const QList &info); - private: Q_DISABLE_COPY(MImServerConnection) diff --git a/connection/minputcontextconnection.cpp b/connection/minputcontextconnection.cpp index c62609e2..403d2950 100644 --- a/connection/minputcontextconnection.cpp +++ b/connection/minputcontextconnection.cpp @@ -346,11 +346,6 @@ void MInputContextConnection::setExtendedAttribute( { Q_EMIT extendedAttributeChanged(connectionId, id, target, targetName, attribute, value); } - -void MInputContextConnection::loadPluginSettings(int connectionId, const QString &descriptionLanguage) -{ - Q_EMIT pluginSettingsRequested(connectionId, descriptionLanguage); -} /* End handlers for inbound communication */ bool MInputContextConnection::detectableAutoRepeat() @@ -544,14 +539,6 @@ void MInputContextConnection::notifyExtendedAttributeChanged(const QList &, // empty default implementation } -void MInputContextConnection::pluginSettingsLoaded(int clientId, const QList &info) -{ - Q_UNUSED(clientId); - Q_UNUSED(info); - - // empty default implementation -} - QVariantMap MInputContextConnection::widgetState() const { diff --git a/connection/minputcontextconnection.h b/connection/minputcontextconnection.h index c9d223fb..37300af9 100644 --- a/connection/minputcontextconnection.h +++ b/connection/minputcontextconnection.h @@ -26,7 +26,6 @@ QT_END_NAMESPACE class MInputContextConnectionPrivate; class MAbstractInputMethod; class MAttributeExtensionId; -class MImPluginSettingsInfo; /*! \internal * \ingroup maliitserver @@ -288,11 +287,6 @@ class MInputContextConnection: public QObject void setExtendedAttribute(unsigned int clientId, int id, const QString &target, const QString &targetItem, const QString &attribute, const QVariant &value); - /*! - * \brief Requests information about plugin/server settings. - */ - void loadPluginSettings(int connectionId, const QString &descriptionLanguage); - public Q_SLOTS: //! Update \a region covered by virtual keyboard virtual void updateInputMethodArea(const QRegion ®ion); @@ -318,11 +312,6 @@ public Q_SLOTS: const QString &attribute, const QVariant &value); - /*! - * \brief Sends the list of plugin/server settings to the specified client. - */ - virtual void pluginSettingsLoaded(int clientId, const QList &info); - Q_SIGNALS: /* Emitted first */ void contentOrientationAboutToChange(int angle); @@ -350,7 +339,6 @@ public Q_SLOTS: void extendedAttributeChanged(unsigned int connectionId, int id, const QString &target, const QString &targetName,const QString &attribute, const QVariant &value); - void pluginSettingsRequested(int connectionId, const QString &descriptionLanguage); void clientActivated(unsigned int connectionId); void clientDisconnected(unsigned int connectionId); diff --git a/dbus_interfaces/minputmethodcontext1interface.xml b/dbus_interfaces/minputmethodcontext1interface.xml index 2b059519..dc0444c5 100644 --- a/dbus_interfaces/minputmethodcontext1interface.xml +++ b/dbus_interfaces/minputmethodcontext1interface.xml @@ -69,9 +69,5 @@ - - - - diff --git a/dbus_interfaces/minputmethodserver1interface.xml b/dbus_interfaces/minputmethodserver1interface.xml index fda83120..9dcde183 100644 --- a/dbus_interfaces/minputmethodserver1interface.xml +++ b/dbus_interfaces/minputmethodserver1interface.xml @@ -62,9 +62,6 @@ - - - diff --git a/examples/plugins/cxx/helloworld/helloworldinputmethod.cpp b/examples/plugins/cxx/helloworld/helloworldinputmethod.cpp index d33febea..ec05c5c8 100644 --- a/examples/plugins/cxx/helloworld/helloworldinputmethod.cpp +++ b/examples/plugins/cxx/helloworld/helloworldinputmethod.cpp @@ -47,19 +47,8 @@ HelloWorldInputMethod::HelloWorldInputMethod(MAbstractInputMethodHost *host) , showIsInhibited(false) , showRequested(false) { - // Register setting - QVariantMap buttonTextAttributes; - - buttonTextAttributes[Maliit::SettingEntryAttributes::defaultValue] = "Hello World!"; - - buttonText.reset(host->registerPluginSetting("button_text", QT_TR_NOOP("Button text"), - Maliit::StringType, buttonTextAttributes)); - - connect(buttonText.data(), SIGNAL(valueChanged()), - this, SLOT(handleButtonTextChanged())); - // Set up UI - mainWidget->setText(buttonText->value().toString()); + mainWidget->setText(QStringLiteral("Button text")); connect(mainWidget, SIGNAL(clicked()), this, SLOT(handleButtonClicked())); // Used only for unittest/sanity test @@ -76,11 +65,6 @@ void HelloWorldInputMethod::handleButtonClicked() inputMethodHost()->sendCommitString(mainWidget->text()); } -void HelloWorldInputMethod::handleButtonTextChanged() -{ - mainWidget->setText(buttonText->value().toString()); -} - void HelloWorldInputMethod::show() { showRequested = true; diff --git a/examples/plugins/cxx/helloworld/helloworldinputmethod.h b/examples/plugins/cxx/helloworld/helloworldinputmethod.h index dcd74ec2..ca87bd4c 100644 --- a/examples/plugins/cxx/helloworld/helloworldinputmethod.h +++ b/examples/plugins/cxx/helloworld/helloworldinputmethod.h @@ -15,7 +15,6 @@ #define HELLO_WORLD_INPUT_METHOD_H #include -#include #include #include @@ -69,11 +68,9 @@ class HelloWorldInputMethod private Q_SLOTS: void handleButtonClicked(); - void handleButtonTextChanged(); private: QScopedPointer surface; - QScopedPointer buttonText; QPushButton *mainWidget; bool showIsInhibited; bool showRequested; diff --git a/maliit-glib/maliitbus.c b/maliit-glib/maliitbus.c index 7873489e..84869d36 100644 --- a/maliit-glib/maliitbus.c +++ b/maliit-glib/maliitbus.c @@ -239,17 +239,6 @@ maliit_get_server_sync (GCancellable *cancellable, return server; } -static gboolean -maliit_context_handle_plugin_settings_loaded (MaliitContext *context, - GDBusMethodInvocation *invocation, - GVariant *plugins G_GNUC_UNUSED, - gpointer user_data G_GNUC_UNUSED) -{ - maliit_context_complete_plugin_settings_loaded (context, invocation); - - return TRUE; -} - static gboolean maliit_context_handle_update_input_method_area (MaliitContext *context, GDBusMethodInvocation *invocation, @@ -297,11 +286,6 @@ maliit_get_context_sync (GCancellable *cancellable, { context = maliit_context_skeleton_new (); - g_signal_connect_after (context, - "handle-plugin-settings-loaded", - G_CALLBACK (maliit_context_handle_plugin_settings_loaded), - NULL); - g_signal_connect_after (context, "handle-update-input-method-area", G_CALLBACK (maliit_context_handle_update_input_method_area), diff --git a/maliit-glib/maliitsettingsmanager.c b/maliit-glib/maliitsettingsmanager.c index bb8759eb..355be7bf 100644 --- a/maliit-glib/maliitsettingsmanager.c +++ b/maliit-glib/maliitsettingsmanager.c @@ -308,15 +308,7 @@ maliit_settings_manager_load_plugin_settings (MaliitSettingsManager *manager) server = maliit_get_server_sync (NULL, &error); - if (server) { - if (!maliit_server_call_load_plugin_settings_sync (server, - maliit_settings_manager_get_preferred_description_locale (), - NULL, - &error)) { - g_warning ("Unable to load plugin settings: %s", error->message); - g_clear_error (&error); - } - } else { + if (!server) { g_warning ("Unable to connect to server: %s", error->message); g_clear_error (&error); } diff --git a/src/maliit/plugins/abstractinputmethodhost.h b/src/maliit/plugins/abstractinputmethodhost.h index 66a46236..29d7b069 100644 --- a/src/maliit/plugins/abstractinputmethodhost.h +++ b/src/maliit/plugins/abstractinputmethodhost.h @@ -32,12 +32,6 @@ class MImPluginDescription; class MImSubViewDescription; class MAbstractInputMethodHostPrivate; -namespace Maliit { -namespace Plugins { - class AbstractPluginSetting; -} -} - /*! \ingroup maliitserver * \brief Provides an interface for input method instances to connect to the environment. * @@ -295,22 +289,6 @@ public Q_SLOTS: */ virtual void setLanguage(const QString &language); - /*! - * \brief Register a new plugin setting - * \param key name for the entry - * \param type value type - * \param attributes attribute map, the same used in SettingsEntry - * - * Returns an object (owned by the plugin) that can be used to manipulate the setting entry. - * - * \sa Maliit::SettingEntryAttributes - * \sa Maliit::SettingsEntry - */ - virtual Maliit::Plugins::AbstractPluginSetting *registerPluginSetting(const QString &key, - const QString &description, - Maliit::SettingEntryType type, - const QVariantMap &attributes) = 0; - private: Q_DISABLE_COPY(MAbstractInputMethodHost) Q_DECLARE_PRIVATE(MAbstractInputMethodHost) diff --git a/src/maliit/plugins/abstractpluginsetting.h b/src/maliit/plugins/abstractpluginsetting.h deleted file mode 100644 index 69dfe83c..00000000 --- a/src/maliit/plugins/abstractpluginsetting.h +++ /dev/null @@ -1,69 +0,0 @@ -/* This file is part of Maliit framework - * - * Copyright (C) 2012 Mattia Barbon - * - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the licence, or (at your option) any later version. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef MALIIT_PLUGIN_SETTINGS_H -#define MALIIT_PLUGIN_SETTINGS_H - -#include - -namespace Maliit { -namespace Plugins { - -/*! \ingroup maliitserver - * \brief A generic interface to access plugin configuration values - */ -class AbstractPluginSetting : public QObject -{ - Q_OBJECT - -public: - //! Returns the key of this item, as given to MAbstractInputMethodHost::registerPluginSetting() - virtual QString key() const = 0; - - //! Returns the current value of this item, as a QVariant. - virtual QVariant value() const = 0; - - /*! Returns the current value of this item, as a QVariant. If - * there is no value for this item, return \a def instead. - */ - virtual QVariant value(const QVariant &def) const = 0; - - /*! Set the value of this item to \a val. If string \a val fails - for any reason, the current value is not changed and nothing happens. - */ - virtual void set(const QVariant &val) = 0; - - /*! Unset this item. This is equivalent to - - \code - item.set(QVariant(QVariant::Invalid)); - \endcode - */ - virtual void unset() = 0; - - //! Emitted when the value of this item has changed. - Q_SIGNAL void valueChanged(); -}; - -} -} - -#endif diff --git a/src/maliit/standaloneinputmethod.cpp b/src/maliit/standaloneinputmethod.cpp index 0ef25b33..45008a27 100644 --- a/src/maliit/standaloneinputmethod.cpp +++ b/src/maliit/standaloneinputmethod.cpp @@ -69,10 +69,6 @@ StandaloneInputMethod::StandaloneInputMethod(Maliit::Plugins::InputMethodPlugin connect(mConnection.get(), &MInputContextConnection::widgetStateChanged, this, &StandaloneInputMethod::handleWidgetStateChanged); - -// connect(d->mICConnection.data(), SIGNAL(pluginSettingsRequested(int,QString)), -// this, SLOT(pluginSettingsRequested(int,QString))); - } StandaloneInputMethod::~StandaloneInputMethod() diff --git a/src/maliit/standaloneinputmethodhost.cpp b/src/maliit/standaloneinputmethodhost.cpp index 20e630a5..4286fe0f 100644 --- a/src/maliit/standaloneinputmethodhost.cpp +++ b/src/maliit/standaloneinputmethodhost.cpp @@ -172,17 +172,9 @@ QList StandaloneInputMethodHost::pluginDescriptions(Maliit return QList(); } -Maliit::Plugins::AbstractPluginSetting *StandaloneInputMethodHost::registerPluginSetting(const QString &key, - const QString &description, - Maliit::SettingEntryType type, - const QVariantMap &attributes) -{ - return nullptr; -} - QVariant StandaloneInputMethodHost::inputMethodQuery(Qt::InputMethodQuery query, const QVariant &argument) const { return mConnection->inputMethodQuery(query, argument); } -} \ No newline at end of file +} diff --git a/src/maliit/standaloneinputmethodhost.h b/src/maliit/standaloneinputmethodhost.h index c7c5f107..a9042303 100644 --- a/src/maliit/standaloneinputmethodhost.h +++ b/src/maliit/standaloneinputmethodhost.h @@ -58,10 +58,6 @@ class StandaloneInputMethodHost : public MAbstractInputMethodHost void setSelection(int start, int length) override; void setOrientationAngleLocked(bool lock) override; QList pluginDescriptions(Maliit::HandlerState state) const override; - Maliit::Plugins::AbstractPluginSetting *registerPluginSetting(const QString &key, - const QString &description, - Maliit::SettingEntryType type, - const QVariantMap &attributes) override; bool hiddenText(bool &valid) override; void setLanguage(const QString &language) override; QVariant inputMethodQuery(Qt::InputMethodQuery query, const QVariant &argument) const override; diff --git a/src/mimpluginmanager.cpp b/src/mimpluginmanager.cpp index b5048a60..98dc5a61 100644 --- a/src/mimpluginmanager.cpp +++ b/src/mimpluginmanager.cpp @@ -50,7 +50,6 @@ namespace const QString MImPluginDisabled = ConfigRoot + "disabledpluginfiles"; const QString PluginRoot = MALIIT_CONFIG_ROOT"plugins"; - const QString PluginSettings = MALIIT_CONFIG_ROOT"pluginsettings"; const QString MImAccesoryEnabled = MALIIT_CONFIG_ROOT"accessoryenabled"; const char * const InputMethodItem = "inputMethod"; @@ -149,7 +148,7 @@ bool MIMPluginManagerPrivate::loadPlugin(const QDir &dir, const QString &fileNam plugin = qobject_cast(pluginInstance); if (!plugin) { qCWarning(lcMaliitFw) << Q_FUNC_INFO << pluginInstance->metaObject()->className() - << "is not a Maliit::Server::InputMethodPlugin."; + << "is not a Maliit::Server::InputMethodPlugin." << fileName; return false; } } @@ -233,86 +232,6 @@ void MIMPluginManagerPrivate::addHandlerMap(Maliit::HandlerState state, } -MImPluginSettingsInfo MIMPluginManagerPrivate::globalSettings() const -{ - QStringList domain, descriptions; - - Q_FOREACH (Maliit::Plugins::InputMethodPlugin *plugin, plugins.keys()) { - const MIMPluginManagerPrivate::PluginDescription &descr = plugins[plugin]; - QList subviews = descr.inputMethod->subViews(); - - Q_FOREACH (const MAbstractInputMethod::MInputMethodSubView &subview, subviews) { - domain.append(descr.pluginId + ":" + subview.subViewId); - descriptions.append(plugin->name() + " - " + subview.subViewTitle); - } - } - - MImPluginSettingsEntry active_subviews; - - active_subviews.extension_key = MALIIT_CONFIG_ROOT"onscreen/active"; - active_subviews.description = QT_TRANSLATE_NOOP("maliit", "Active subview"); - active_subviews.type = Maliit::StringType; - active_subviews.attributes[Maliit::SettingEntryAttributes::valueDomain] = domain; - active_subviews.attributes[Maliit::SettingEntryAttributes::valueDomainDescriptions] = descriptions; - - MImPluginSettingsEntry enabled_subviews; - - enabled_subviews.extension_key = MALIIT_CONFIG_ROOT"onscreen/enabled"; - enabled_subviews.description = QT_TRANSLATE_NOOP("maliit", "Enabled subviews"); - enabled_subviews.type = Maliit::StringListType; - enabled_subviews.attributes[Maliit::SettingEntryAttributes::valueDomain] = domain; - enabled_subviews.attributes[Maliit::SettingEntryAttributes::valueDomainDescriptions] = descriptions; - - MImPluginSettingsInfo global; - - global.plugin_description = QT_TRANSLATE_NOOP("maliit", "Global"); - global.plugin_name = "server"; - global.extension_id = MSharedAttributeExtensionManager::PluginSettings; - global.entries.append(active_subviews); - global.entries.append(enabled_subviews); - - return global; -} - - -void MIMPluginManagerPrivate::registerSettings() -{ - // not exposed to final user, merely used to listen for settings list changes - MImPluginSettingsInfo settings_list; - - settings_list.plugin_name = "@settings"; - settings_list.extension_id = MSharedAttributeExtensionManager::PluginSettingsList; - - registerSettings(settings_list); - - // global settings - registerSettings(globalSettings()); -} - - -void MIMPluginManagerPrivate::registerSettings(const MImPluginSettingsInfo &info) -{ - bool found = false; - - for (int i = 0; i < settings.size(); ++i) { - if (settings[i].plugin_name == info.plugin_name) { - found = true; - settings[i].entries.append(info.entries); - break; - } - } - - // No setting info for this plugin yet: add the whole entry - if (!found) { - settings.append(info); - } - - Q_FOREACH (const MImPluginSettingsEntry &entry, info.entries) { - sharedAttributeExtensionManager->registerPluginSetting(entry.extension_key, entry.type, entry.attributes); - } -} - - void MIMPluginManagerPrivate::setActiveHandlers(const QSet &states) { QSet activatedPlugins; @@ -1172,9 +1091,6 @@ MIMPluginManager::MIMPluginManager(const QSharedPointer connect(d->mICConnection.data(), SIGNAL(clientDisconnected(uint)), d->sharedAttributeExtensionManager.data(), SLOT(handleClientDisconnect(uint))); - connect(d->mICConnection.data(), SIGNAL(pluginSettingsRequested(int,QString)), - this, SLOT(pluginSettingsRequested(int,QString))); - connect(d->mICConnection.data(), SIGNAL(focusChanged(WId)), this, SLOT(handleAppFocusChanged(WId))); @@ -1195,8 +1111,6 @@ MIMPluginManager::MIMPluginManager(const QSharedPointer d->loadHandlerMap(); - d->registerSettings(); - connect(&d->onScreenPlugins, SIGNAL(activeSubViewChanged()), this, SLOT(_q_onScreenSubViewChanged())); d->_q_onScreenSubViewChanged(); @@ -1575,82 +1489,4 @@ void MIMPluginManager::onGlobalAttributeChanged(const MAttributeExtensionId &id, } } -void MIMPluginManager::pluginSettingsRequested(int clientId, const QString &descriptionLanguage) -{ - Q_D(MIMPluginManager); - - QList settings = d->settings; - - for (int i = 0; i < settings.count(); ++i) { - QList &entries = settings[i].entries; - - // TODO translate descriptions using descriptionLanguage - settings[i].description_language = descriptionLanguage; - - for (int j = 0; j < entries.count(); ++j) { - // TODO translate descriptions using descriptionLanguage - entries[j].value = MImSettings(entries[j].extension_key).value(entries[j].attributes.value(Maliit::SettingEntryAttributes::defaultValue)); - } - } - - d->mICConnection->pluginSettingsLoaded(clientId, settings); -} - -AbstractPluginSetting *MIMPluginManager::registerPluginSetting(const QString &pluginId, - const QString &pluginDescription, - const QString &key, - const QString &description, - Maliit::SettingEntryType type, - const QVariantMap &attributes) -{ - Q_D(MIMPluginManager); - - MImPluginSettingsEntry entry; - entry.description = description; - entry.type = type; - entry.extension_key = PluginSettings + "/" + pluginId + "/" + key; - entry.attributes = attributes; - - MImPluginSettingsInfo info; - info.plugin_name = pluginId; - info.plugin_description = pluginDescription; - info.extension_id = MSharedAttributeExtensionManager::PluginSettings; - info.entries.append(entry); - - d->registerSettings(info); - - return new PluginSetting(key, entry.extension_key, entry.attributes.value(Maliit::SettingEntryAttributes::defaultValue)); -} - -PluginSetting::PluginSetting(const QString &shortKey, const QString &fullKey, const QVariant &value) : - pluginKey(shortKey), setting(fullKey), defaultValue(value) -{ - connect(&setting, SIGNAL(valueChanged()), this, SIGNAL(valueChanged())); -} - -QString PluginSetting::key() const -{ - return pluginKey; -} - -QVariant PluginSetting::value() const -{ - return setting.value(defaultValue); -} - -QVariant PluginSetting::value(const QVariant &def) const -{ - return setting.value(def.isValid() ? def : defaultValue); -} - -void PluginSetting::set(const QVariant &val) -{ - setting.set(val); -} - -void PluginSetting::unset() -{ - setting.unset(); -} - #include "moc_mimpluginmanager.cpp" diff --git a/src/mimpluginmanager.h b/src/mimpluginmanager.h index fd9d7385..de710301 100644 --- a/src/mimpluginmanager.h +++ b/src/mimpluginmanager.h @@ -38,11 +38,7 @@ namespace Maliit { class AbstractPlatform; -namespace Plugins { - class AbstractPluginSetting; } -} -using Maliit::Plugins::AbstractPluginSetting; //! \internal /*! \ingroup maliitserver @@ -106,14 +102,6 @@ class MIMPluginManager: public QObject //! Enables all installed subviews void setAllSubViewsEnabled(bool enable); - //! Register a setting entry for the specified plugin - AbstractPluginSetting *registerPluginSetting(const QString &pluginId, - const QString &pluginDescription, - const QString &key, - const QString &description, - Maliit::SettingEntryType type, - const QVariantMap &attributes); - Q_SIGNALS: //! This signal is emitted when input method plugins are loaded, unloaded, //! enabled or disabled @@ -155,8 +143,6 @@ private Q_SLOTS: Qt::KeyboardModifiers modifiers, const QString &text, bool autoRepeat, int count, quint32 nativeScanCode, quint32 nativeModifiers, unsigned long time); - void pluginSettingsRequested(int clientId, const QString &descriptionLanguage); - /*! * \brief Handle global attribute change * \param id id of the attribute extension that triggered this change diff --git a/src/mimpluginmanager_p.h b/src/mimpluginmanager_p.h index 783826d5..eb79d24a 100644 --- a/src/mimpluginmanager_p.h +++ b/src/mimpluginmanager_p.h @@ -22,7 +22,6 @@ #include "mimsettings.h" #include "mimhwkeyboardtracker.h" #include -#include #include "windowgroup.h" #include "abstractplatform.h" @@ -42,26 +41,6 @@ class MImSettings; class MAbstractInputMethod; class MIMPluginManagerAdaptor; -/* Internal class only! Interfaces here change, internal developers only*/ -class PluginSetting : public Maliit::Plugins::AbstractPluginSetting -{ - Q_OBJECT - -public: - PluginSetting(const QString &shortKey, const QString &fullKey, const QVariant &value); - - virtual QString key() const; - virtual QVariant value() const; - virtual QVariant value(const QVariant &def) const; - virtual void set(const QVariant &val); - virtual void unset(); - -private: - QString pluginKey; - MImSettings setting; - QVariant defaultValue; -}; - /* Internal class only! Interfaces here change, internal developers only*/ class MIMPluginManagerPrivate { @@ -98,9 +77,6 @@ class MIMPluginManagerPrivate void loadPlugins(); bool loadPlugin(const QDir &dir, const QString &fileName); void addHandlerMap(Maliit::HandlerState state, const QString &pluginName); - void registerSettings(); - void registerSettings(const MImPluginSettingsInfo &info); - MImPluginSettingsInfo globalSettings() const; void setActiveHandlers(const QSet &states); QSet activeHandlers() const; void deactivatePlugin(Maliit::Plugins::InputMethodPlugin *plugin); @@ -174,7 +150,6 @@ class MIMPluginManagerPrivate Plugins plugins; ActivePlugins activePlugins; QSet targets; - QList settings; QStringList paths; QStringList blacklist; diff --git a/src/minputmethodhost.cpp b/src/minputmethodhost.cpp index fb428679..a4a79625 100644 --- a/src/minputmethodhost.cpp +++ b/src/minputmethodhost.cpp @@ -240,14 +240,6 @@ int MInputMethodHost::anchorPosition(bool &valid) return connection->anchorPosition(valid); } -AbstractPluginSetting *MInputMethodHost::registerPluginSetting(const QString &key, - const QString &description, - Maliit::SettingEntryType type, - const QVariantMap &attributes) -{ - return pluginManager->registerPluginSetting(pluginId, pluginDescription, key, description, type, attributes); -} - QVariant MInputMethodHost::inputMethodQuery(Qt::InputMethodQuery query, const QVariant &argument) const { return connection->inputMethodQuery(query, argument); diff --git a/src/minputmethodhost.h b/src/minputmethodhost.h index 7a1de7e9..f844b54e 100644 --- a/src/minputmethodhost.h +++ b/src/minputmethodhost.h @@ -31,8 +31,6 @@ QT_BEGIN_NAMESPACE class QRegion; QT_END_NAMESPACE -using Maliit::Plugins::AbstractPluginSetting; - /*! \internal * \ingroup maliitserver * \brief Interface implementation for connecting input method instances to the environment. @@ -98,10 +96,6 @@ class MInputMethodHost: public MAbstractInputMethodHost //! Only empty implementation provided. virtual void setOrientationAngleLocked(bool lock); - virtual AbstractPluginSetting *registerPluginSetting(const QString &key, - const QString &description, - Maliit::SettingEntryType type, - const QVariantMap &attributes); // \reimp_end QVariant inputMethodQuery(Qt::InputMethodQuery query, const QVariant &argument) const override; diff --git a/src/msharedattributeextensionmanager.cpp b/src/msharedattributeextensionmanager.cpp index e8bf50b5..1c589570 100644 --- a/src/msharedattributeextensionmanager.cpp +++ b/src/msharedattributeextensionmanager.cpp @@ -36,17 +36,6 @@ MSharedAttributeExtensionManager::~MSharedAttributeExtensionManager() { } -void MSharedAttributeExtensionManager::registerPluginSetting(const QString &fullName, Maliit::SettingEntryType type, - QVariantMap attributes) -{ - QString key = fullName.section(1, -1); - QSharedPointer value(new MSharedAttributeExtensionManagerPluginSetting(key, type, attributes)); - - sharedAttributeExtensions[key] = value; - - connect(&value.data()->setting, SIGNAL(valueChanged()), this, SLOT(attributeValueChanged())); -} - void MSharedAttributeExtensionManager::handleClientDisconnect(unsigned int clientId) { clientIds.removeOne(clientId); diff --git a/src/msharedattributeextensionmanager.h b/src/msharedattributeextensionmanager.h index 4bb1dff1..047ac172 100644 --- a/src/msharedattributeextensionmanager.h +++ b/src/msharedattributeextensionmanager.h @@ -41,13 +41,6 @@ class MSharedAttributeExtensionManager : public QObject MSharedAttributeExtensionManager(); virtual ~MSharedAttributeExtensionManager(); - /*! - * \brief Add a new setting entry to the extension manager - * - * \sa Maliit::SettingsEntry, MImPluginSettingsEntry - */ - void registerPluginSetting(const QString &fullName, Maliit::SettingEntryType type, QVariantMap attributes); - public Q_SLOTS: void handleClientDisconnect(unsigned int clientId); void handleAttributeExtensionRegistered(unsigned int clientId, int id, const QString &attributeExtension); diff --git a/tests/dummyimplugin3/dummyinputmethod3.cpp b/tests/dummyimplugin3/dummyinputmethod3.cpp index 106d81ca..803f36bf 100644 --- a/tests/dummyimplugin3/dummyinputmethod3.cpp +++ b/tests/dummyimplugin3/dummyinputmethod3.cpp @@ -31,12 +31,6 @@ DummyInputMethod3::DummyInputMethod3(MAbstractInputMethodHost *host) QVariantMap settingAttributes; settingAttributes[Maliit::SettingEntryAttributes::defaultValue] = "Test"; - - setting.reset(host->registerPluginSetting("setting", QT_TR_NOOP("Example setting"), - Maliit::StringType, settingAttributes)); - - connect(setting.data(), SIGNAL(valueChanged()), - this, SLOT(handleSettingChanged())); } void DummyInputMethod3::setState(const QSet &state) @@ -91,8 +85,3 @@ void DummyInputMethod3::show() inputMethodHost()->setScreenRegion(QRegion(0, 0, 100, 100)); Q_EMIT showCalled(); } - -void DummyInputMethod3::handleSettingChanged() -{ - localSettingValue = setting->value(); -} diff --git a/tests/dummyimplugin3/dummyinputmethod3.h b/tests/dummyimplugin3/dummyinputmethod3.h index 6f25c478..ceec3221 100644 --- a/tests/dummyimplugin3/dummyinputmethod3.h +++ b/tests/dummyimplugin3/dummyinputmethod3.h @@ -2,7 +2,6 @@ #define DUMMYINPUTMETHOD3_H #include -#include #include class DummyInputMethod3 : public MAbstractInputMethod @@ -32,15 +31,10 @@ class DummyInputMethod3 : public MAbstractInputMethod Maliit::SwitchDirection directionParam; bool enableAnimationParam; - QVariant localSettingValue; - QScopedPointer setting; - Q_SIGNALS: void showCalled(); private: - Q_SLOT void handleSettingChanged(); - void addSubView(const QString &id, const QString &title); QList sViews; diff --git a/tests/ft_mimpluginmanager/ft_mimpluginmanager.cpp b/tests/ft_mimpluginmanager/ft_mimpluginmanager.cpp index 32ba5ddc..4eaba2f9 100644 --- a/tests/ft_mimpluginmanager/ft_mimpluginmanager.cpp +++ b/tests/ft_mimpluginmanager/ft_mimpluginmanager.cpp @@ -35,7 +35,6 @@ namespace const QString MImPluginDisabled = ConfigRoot + "disabledpluginfiles"; const QString PluginRoot = MALIIT_CONFIG_ROOT"plugins/"; - const QString PluginSettings = MALIIT_CONFIG_ROOT"pluginsettings"; const QString MImAccesoryEnabled = MALIIT_CONFIG_ROOT"accessoryenabled"; const MImPluginDescription* findPluginDescriptions(const QList &list, const QString &pluginName) @@ -79,10 +78,8 @@ void Ft_MIMPluginManager::init() enabledPlugins << pluginId3 + ":" + "dummyim3sv2"; enabledPluginsSettings.set(enabledPlugins); - MImSettings activePluginSettings(ActivePluginKey); QString activePlugin; activePlugin = pluginId + ":" + "dummyimsv1"; - activePluginSettings.set(activePlugin); gMKeyboardStateTrackerStub->setOpenState(false); MImSettings(MImAccesoryEnabled).set(QVariant(false)); @@ -251,91 +248,5 @@ void Ft_MIMPluginManager::testPluginDescriptions() Q_DECLARE_METATYPE(QList) -void Ft_MIMPluginManager::testPluginSetting() -{ - qRegisterMetaType >(); - - QString pluginId; - QSignalSpy spy(subject->d_ptr->sharedAttributeExtensionManager.data(), - SIGNAL(notifyExtensionAttributeChanged(QList,int,QString,QString,QString,QVariant))); - QList arguments; - - DummyImPlugin3 *plugin = 0; - DummyInputMethod3 *inputMethod = 0; - - for (MIMPluginManagerPrivate::Plugins::iterator iterator(subject->d_ptr->plugins.begin()); - iterator != subject->d_ptr->plugins.end(); - ++iterator) { - if (pluginName3 == iterator.key()->name()) { - plugin = dynamic_cast(iterator.key()); - pluginId = iterator.value().pluginId; - } - } - - QVERIFY(plugin != 0); - inputMethod = dynamic_cast(subject->d_ptr->plugins[plugin].inputMethod); - QVERIFY(inputMethod != 0); - - QCOMPARE(inputMethod->setting->value(), QVariant("Test")); - - QString settingKey = PluginSettings + "/" + pluginId + "/setting"; - - // tests - // - that plugin settings are registered in a per-plugin namespace - // - that they are correctly registered in the shared attribute extension manager - // - that the data returned to clients reflects plugin settings - // - that changing setting value notifies both subscribed clients and the plugin - - // setting registered in global setting list - bool setting_registered = false; - - Q_FOREACH (const MImPluginSettingsInfo &info, subject->d_ptr->settings) { - if (info.plugin_name == pluginId) { - setting_registered = true; - - QCOMPARE(info.plugin_description, QString("DummyImPlugin3")); - QCOMPARE(info.entries.count(), 1); - QCOMPARE(info.entries[0].description, QString("Example setting")); - QCOMPARE(info.entries[0].extension_key, settingKey); - QCOMPARE(info.entries[0].type, Maliit::StringType); - QCOMPARE(info.entries[0].attributes[Maliit::SettingEntryAttributes::defaultValue], QVariant("Test")); - break; - } - } - - QVERIFY(setting_registered); - - // simulate client susbcription - subject->d_ptr->sharedAttributeExtensionManager->handleAttributeExtensionRegistered(12, MSharedAttributeExtensionManager::PluginSettings, settingKey); - - MImSettings setting(settingKey); - - // setting the value from the server - setting.set("Test1"); - - QCOMPARE(spy.count(), 1); - QCOMPARE(inputMethod->setting->value(), QVariant("Test1")); - QCOMPARE(inputMethod->localSettingValue, QVariant("Test1")); - - arguments = spy[0]; - QCOMPARE(arguments[2], QVariant("/maliit")); - QCOMPARE(arguments[3], QVariant("pluginsettings/" + pluginId)); - QCOMPARE(arguments[4], QVariant("setting")); - QCOMPARE(arguments[5].value(), QVariant("Test1")); - - // setting the value from the plugin - inputMethod->setting->set("Test2"); - - QCOMPARE(spy.count(), 2); - QCOMPARE(setting.value(), QVariant("Test2")); - QCOMPARE(inputMethod->localSettingValue, QVariant("Test2")); - - arguments = spy[1]; - QCOMPARE(arguments[2], QVariant("/maliit")); - QCOMPARE(arguments[3], QVariant("pluginsettings/" + pluginId)); - QCOMPARE(arguments[4], QVariant("setting")); - QCOMPARE(arguments[5].value(), QVariant("Test2")); -} - QTEST_MAIN(Ft_MIMPluginManager) diff --git a/tests/ft_mimpluginmanager/ft_mimpluginmanager.h b/tests/ft_mimpluginmanager/ft_mimpluginmanager.h index 829960cb..0e9cf02e 100644 --- a/tests/ft_mimpluginmanager/ft_mimpluginmanager.h +++ b/tests/ft_mimpluginmanager/ft_mimpluginmanager.h @@ -26,7 +26,6 @@ private Q_SLOTS: void testSwitchPluginBySignal(); void testSwitchToSpecifiedPlugin(); void testPluginDescriptions(); - void testPluginSetting(); private: MIMPluginManager *subject; diff --git a/tests/ut_maliit_glib_settings/mockmaliitserver.c b/tests/ut_maliit_glib_settings/mockmaliitserver.c index d387e1e4..ed4d7d19 100644 --- a/tests/ut_maliit_glib_settings/mockmaliitserver.c +++ b/tests/ut_maliit_glib_settings/mockmaliitserver.c @@ -44,21 +44,6 @@ struct _MockMaliitServerPriv { GMutex thread_mutex; }; -/* Record the call, and respond with a list of settings */ -gboolean -load_plugin_settings (MaliitServer *server, - GDBusMethodInvocation *invocation, - const gchar *locale_name G_GNUC_UNUSED, - gpointer user_data) -{ - MockMaliitServer *self = user_data; - - self->load_plugin_settings_called = TRUE; - - maliit_server_complete_load_plugin_settings(server, invocation); - return TRUE; -} - static gboolean start_server(gpointer user_data) { @@ -73,7 +58,6 @@ start_server(gpointer user_data) self->priv->server_connection, SERVER_OBJECT_PATH, NULL)); - g_signal_connect(self->priv->server, "handle-load-plugin-settings", G_CALLBACK(load_plugin_settings), self); g_cond_signal(&self->priv->thread_cond); g_mutex_unlock(&self->priv->thread_mutex); diff --git a/tests/ut_maliit_glib_settings/mockmaliitserver.h b/tests/ut_maliit_glib_settings/mockmaliitserver.h index e6768cbe..eaaa614c 100644 --- a/tests/ut_maliit_glib_settings/mockmaliitserver.h +++ b/tests/ut_maliit_glib_settings/mockmaliitserver.h @@ -28,7 +28,6 @@ typedef struct _MockMaliitServerPriv MockMaliitServerPriv; typedef struct { - gboolean load_plugin_settings_called; MockMaliitServerPriv *priv; GVariant *settings; /* To be set by tests */ } MockMaliitServer; diff --git a/tests/ut_maliit_glib_settings/ut_maliit_glib_settings.c b/tests/ut_maliit_glib_settings/ut_maliit_glib_settings.c index 3049805e..07069c5d 100644 --- a/tests/ut_maliit_glib_settings/ut_maliit_glib_settings.c +++ b/tests/ut_maliit_glib_settings/ut_maliit_glib_settings.c @@ -99,43 +99,6 @@ test_preferred_description_locale_set_get_roundtrip(void) g_assert_cmpstr(actual, ==, expected); } -void -add_gobject_ref_gfunc(gpointer data, gpointer user_data G_GNUC_UNUSED) -{ - g_object_ref(data); -} - -/** - * Test that calling maliit_settings_manager_load_plugins will return - * a list of settings through the MaliitSettingsManager::plugin-settings-received signal - */ -void -test_load_plugins_settings_returns_settings(void) -{ - MockMaliitServer *server; - MaliitSettingsManager *manager; - - server = mock_maliit_server_new(); - server->settings = g_variant_new_parsed("@a(sssia(ssibva{sv})) [('a', 'b', 'c', 42, [])]"); - maliit_set_bus(mock_maliit_server_get_bus(server)); - - manager = maliit_settings_manager_new(); - maliit_settings_manager_load_plugin_settings(manager); - g_assert(server->load_plugin_settings_called); - - g_object_unref(manager); - maliit_set_bus(NULL); - mock_maliit_server_free(server); -} - - -void -on_signal_received(gpointer instance G_GNUC_UNUSED, gpointer user_data) -{ - gboolean *received = (gboolean *)user_data; - *received = TRUE; -} - int main (int argc, char **argv) { g_test_init(&argc, &argv, NULL); @@ -147,8 +110,6 @@ main (int argc, char **argv) { test_preferred_description_locale_default); g_test_add_func("/ut_maliit_glib_settings/MaliitSettingsManager/preferred_description_locale/set-get-roundtrip", test_preferred_description_locale_set_get_roundtrip); - g_test_add_func("/ut_maliit_glib_settings/MaliitSettingsManager/load_plugin_settings/returns-settings", - test_load_plugins_settings_returns_settings); return g_test_run(); } diff --git a/tests/ut_mimpluginmanager/ut_mimpluginmanager.cpp b/tests/ut_mimpluginmanager/ut_mimpluginmanager.cpp index f952107f..ef114e0f 100644 --- a/tests/ut_mimpluginmanager/ut_mimpluginmanager.cpp +++ b/tests/ut_mimpluginmanager/ut_mimpluginmanager.cpp @@ -64,18 +64,10 @@ class MInputContextTestConnection : public MInputContextConnection { public: MInputContextTestConnection() : - pluginSettingsLoaded_called(0), notifyExtendedAttributeChanged_called(0) { } - void pluginSettingsLoaded(int clientId, const QList &info) - { - pluginSettingsLoaded_called++; - pluginSettingsLoaded_clientId = clientId; - pluginSettingsLoaded_settings = info; - } - void notifyExtendedAttributeChanged(const QList &clientIds, int id, const QString &target, const QString &targetItem, const QString &attribute, const QVariant &value) { Q_UNUSED(id); @@ -86,10 +78,6 @@ class MInputContextTestConnection : public MInputContextConnection notifyExtendedAttributeChanged_value = value; } - int pluginSettingsLoaded_called; - int pluginSettingsLoaded_clientId; - QList pluginSettingsLoaded_settings; - int notifyExtendedAttributeChanged_called; QList notifyExtendedAttributeChanged_clientIds; QString notifyExtendedAttributeChanged_key; @@ -122,9 +110,6 @@ void Ut_MIMPluginManager::init() MImSettings enabledPluginsSettings(EnabledPluginsKey); enabledPluginsSettings.set(DefaultEnabledPlugins); - MImSettings activePluginSettings(ActivePluginKey); - activePluginSettings.set(DefaultActivePlugin); - QSharedPointer icConnection(new MInputContextTestConnection); manager = new MIMPluginManager(icConnection, QSharedPointer(new Maliit::UnknownPlatform)); @@ -132,6 +117,7 @@ void Ut_MIMPluginManager::init() subject = manager->d_ptr; QVERIFY(subject->activePlugins.size() == 1); + subject->setActivePlugin(pluginId, Maliit::OnScreen); Maliit::Plugins::InputMethodPlugin *plugin = 0; plugin = *subject->activePlugins.begin(); QVERIFY(plugin != 0); @@ -820,89 +806,4 @@ void Ut_MIMPluginManager::handleMessages() QCoreApplication::processEvents(); } -void Ut_MIMPluginManager::testPluginSettingsList() -{ - manager->pluginSettingsRequested(42, QString()); - QCOMPARE(connection->pluginSettingsLoaded_called, 1); - QCOMPARE(connection->pluginSettingsLoaded_clientId, 42); - QVERIFY(connection->pluginSettingsLoaded_settings.count() >= 2); - - MImPluginSettingsInfo server, list; - - Q_FOREACH (const MImPluginSettingsInfo &plugin, connection->pluginSettingsLoaded_settings) { - if (plugin.plugin_name == "@settings") - list = plugin; - else if (plugin.plugin_name == "server") - server = plugin; - } - - QVERIFY(!server.plugin_name.isEmpty() && !list.plugin_name.isEmpty()); - - QCOMPARE(list.extension_id, (int)MSharedAttributeExtensionManager::PluginSettingsList); - - QCOMPARE(server.extension_id, (int)MSharedAttributeExtensionManager::PluginSettings); - QVERIFY(server.entries.count() >= 2); -} - -void Ut_MIMPluginManager::testPluginSettingsUpdate() -{ - manager->pluginSettingsRequested(42, QString()); - QCOMPARE(connection->pluginSettingsLoaded_called, 1); - QCOMPARE(connection->pluginSettingsLoaded_clientId, 42); - - MImPluginSettingsInfo server; - MImPluginSettingsEntry enabled; - QString test_key = "/maliit/onscreen/active"; - QVariant original_value, new_value; - - Q_FOREACH (const MImPluginSettingsInfo &plugin, connection->pluginSettingsLoaded_settings) { - if (plugin.plugin_name != "server") - continue; - - server = plugin; - - Q_FOREACH (const MImPluginSettingsEntry &entry, plugin.entries) { - if (entry.extension_key == test_key) - enabled = entry; - } - } - - original_value = enabled.value; - - QVERIFY(!enabled.description.isEmpty()); - QVERIFY(enabled.value.isValid()); - QCOMPARE(enabled.value, MImSettings(test_key).value()); - QCOMPARE(enabled.type, Maliit::StringType); - - Q_FOREACH (const QVariant &v, enabled.attributes[Maliit::SettingEntryAttributes::valueDomain].toList()) { - if (v != original_value) { - new_value = v; - break; - } - } - - subject->sharedAttributeExtensionManager->handleAttributeExtensionRegistered(42, server.extension_id, QString()); - subject->sharedAttributeExtensionManager->handleAttributeExtensionRegistered(43, server.extension_id, QString()); - - // change value from client - subject->sharedAttributeExtensionManager->handleExtendedAttributeUpdate(42, server.extension_id, "/maliit", "onscreen", - "active", new_value); - - QCOMPARE(connection->notifyExtendedAttributeChanged_called, 1); - QCOMPARE(connection->notifyExtendedAttributeChanged_clientIds, QList() << 42 << 43); - QCOMPARE(connection->notifyExtendedAttributeChanged_key, test_key); - QCOMPARE(connection->notifyExtendedAttributeChanged_value, new_value); - - // check unsubscription - subject->sharedAttributeExtensionManager->handleAttributeExtensionUnregistered(43, server.extension_id); - - // change value from server - MImSettings(test_key).set(original_value); - - QCOMPARE(connection->notifyExtendedAttributeChanged_called, 2); - QCOMPARE(connection->notifyExtendedAttributeChanged_clientIds, QList() << 42); - QCOMPARE(connection->notifyExtendedAttributeChanged_key, test_key); - QCOMPARE(connection->notifyExtendedAttributeChanged_value, original_value); -} - QTEST_MAIN(Ut_MIMPluginManager) diff --git a/tests/ut_mimpluginmanager/ut_mimpluginmanager.h b/tests/ut_mimpluginmanager/ut_mimpluginmanager.h index cfbbd1e2..f7741148 100644 --- a/tests/ut_mimpluginmanager/ut_mimpluginmanager.h +++ b/tests/ut_mimpluginmanager/ut_mimpluginmanager.h @@ -51,9 +51,6 @@ private Q_SLOTS: void testEnableAllSubviews(); - void testPluginSettingsList(); - void testPluginSettingsUpdate(); - private: void handleMessages(); diff --git a/tests/ut_mimpluginmanagerconfig/ut_mimpluginmanagerconfig.cpp b/tests/ut_mimpluginmanagerconfig/ut_mimpluginmanagerconfig.cpp index 324b8a9c..910eae93 100644 --- a/tests/ut_mimpluginmanagerconfig/ut_mimpluginmanagerconfig.cpp +++ b/tests/ut_mimpluginmanagerconfig/ut_mimpluginmanagerconfig.cpp @@ -75,16 +75,12 @@ void Ut_MIMPluginManagerConfig::init() MImSettings pathConf(MImPluginPaths); pathConf.set(MaliitTestUtils::getTestPluginPath()); connection = new MInputContextConnection; - enabledPluginSettings = new MImSettings(EnabledPluginsKey); - activePluginSettings = new MImSettings(ActivePluginKey); } void Ut_MIMPluginManagerConfig::cleanup() { delete manager; delete connection; - delete enabledPluginSettings; - delete activePluginSettings; manager = 0; subject = 0; } @@ -94,8 +90,6 @@ void Ut_MIMPluginManagerConfig::cleanup() void Ut_MIMPluginManagerConfig::testNoActiveSubView() { - enabledPluginSettings->set(DefaultEnabledPlugins); - activePluginSettings->unset(); QSharedPointer icConnection(connection); manager = new MIMPluginManager(icConnection, QSharedPointer(new Maliit::UnknownPlatform)); @@ -109,8 +103,6 @@ void Ut_MIMPluginManagerConfig::testNoActiveSubView() void Ut_MIMPluginManagerConfig::testEmptyConfig() { - enabledPluginSettings->unset(); - activePluginSettings->unset(); QSharedPointer icConnection(connection); manager = new MIMPluginManager(icConnection, QSharedPointer(new Maliit::UnknownPlatform)); @@ -127,10 +119,6 @@ void Ut_MIMPluginManagerConfig::testEmptyConfig() void Ut_MIMPluginManagerConfig::autoLanguageSubView() { - // Force autodetection of enabled plugins in DummyPlugin3 - enabledPluginSettings->unset(); - activePluginSettings->set(QStringList() << pluginId3 + ":"); - QSharedPointer icConnection(connection); manager = new MIMPluginManager(icConnection, QSharedPointer(new Maliit::UnknownPlatform)); subject = manager->d_ptr; diff --git a/tests/ut_mimpluginmanagerconfig/ut_mimpluginmanagerconfig.h b/tests/ut_mimpluginmanagerconfig/ut_mimpluginmanagerconfig.h index c313967b..d54b5589 100644 --- a/tests/ut_mimpluginmanagerconfig/ut_mimpluginmanagerconfig.h +++ b/tests/ut_mimpluginmanagerconfig/ut_mimpluginmanagerconfig.h @@ -44,8 +44,6 @@ private Q_SLOTS: private: QString pluginPath; - MImSettings *enabledPluginSettings; - MImSettings *activePluginSettings; MIMPluginManager *manager; MIMPluginManagerPrivate *subject; MInputContextConnection *connection; diff --git a/tests/utils/gui-utils.cpp b/tests/utils/gui-utils.cpp deleted file mode 100644 index 3a4ad89d..00000000 --- a/tests/utils/gui-utils.cpp +++ /dev/null @@ -1,25 +0,0 @@ -/* * This file is part of Maliit framework * - * - * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). - * All rights reserved. - * - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License version 2.1 as published by the Free Software Foundation - * and appearing in the file LICENSE.LGPL included in the packaging - * of this file. - */ - -#include "gui-utils.h" - -#include -#include -#include -#include - -namespace MaliitTestUtils { - - -} - diff --git a/tests/utils/gui-utils.h b/tests/utils/gui-utils.h index 49e0e4de..6750a7d1 100644 --- a/tests/utils/gui-utils.h +++ b/tests/utils/gui-utils.h @@ -21,27 +21,8 @@ #include #include -#include - namespace MaliitTestUtils { - class TestPluginSetting : public Maliit::Plugins::AbstractPluginSetting - { - public: - TestPluginSetting(const QString &key) : settingKey(key) {} - - QString key() const { return settingKey; } - - QVariant value() const { return QVariant(); } - QVariant value(const QVariant &def) const { return def; } - - void set(const QVariant &val) { Q_UNUSED(val); } - void unset() {} - - private: - QString settingKey; - }; - class TestInputMethodHost : public MInputMethodHost { @@ -78,20 +59,7 @@ namespace MaliitTestUtils { ++sendPreeditCount; MInputMethodHost::sendPreeditString(string, preeditFormats, start, length, cursorPos); } - - AbstractPluginSetting *registerPluginSetting(const QString &key, - const QString &description, - Maliit::SettingEntryType type, - const QVariantMap &attributes) - { - Q_UNUSED(description); - Q_UNUSED(type); - Q_UNUSED(attributes); - - return new TestPluginSetting(key); - } }; - } // For cases where we need to run code _before_ QGuiApplication is created From beb3bc988dc8d92929ba012bdc1ac8e639144d92 Mon Sep 17 00:00:00 2001 From: Rodney Dawes Date: Tue, 17 May 2022 13:27:46 -0400 Subject: [PATCH 02/13] Drop the setLanguage API as keyboard language is plugin side --- connection/dbusinputcontextconnection.cpp | 13 -------- connection/dbusinputcontextconnection.h | 3 -- connection/mimserverconnection.h | 7 ----- connection/minputcontextconnection.cpp | 5 ---- connection/minputcontextconnection.h | 6 ---- connection/waylandinputmethodconnection.cpp | 12 -------- connection/waylandinputmethodconnection.h | 1 - .../minputmethodcontext1interface.xml | 3 -- input-context/minputcontext.cpp | 30 ------------------- input-context/minputcontext.h | 4 --- .../plugins/abstractinputmethodhost.cpp | 4 --- src/maliit/plugins/abstractinputmethodhost.h | 8 ----- src/maliit/standaloneinputmethodhost.cpp | 5 ---- src/maliit/standaloneinputmethodhost.h | 1 - src/minputmethodhost.cpp | 7 ----- src/minputmethodhost.h | 1 - 16 files changed, 110 deletions(-) diff --git a/connection/dbusinputcontextconnection.cpp b/connection/dbusinputcontextconnection.cpp index f7bc496e..f4e59fad 100644 --- a/connection/dbusinputcontextconnection.cpp +++ b/connection/dbusinputcontextconnection.cpp @@ -44,7 +44,6 @@ DBusInputContextConnection::DBusInputContextConnection(const QSharedPointerconnect()) , mConnectionNumbers() , mProxys() - , lastLanguage() { connect(mServer.data(), SIGNAL(newConnection(QDBusConnection)), this, SLOT(newConnection(QDBusConnection))); @@ -77,8 +76,6 @@ DBusInputContextConnection::newConnection(const QDBusConnection &connection) this, SLOT(onDisconnection())); c.registerObject(QString::fromLatin1(DBusPath), this); - - proxy->setLanguage(lastLanguage); } void @@ -229,16 +226,6 @@ DBusInputContextConnection::selection(bool &valid) return QString(); } -void -DBusInputContextConnection::setLanguage(const QString &language) -{ - lastLanguage = language; - ComMeegoInputmethodInputcontext1Interface *proxy = mProxys.value(activeConnection); - if (proxy) { - proxy->setLanguage(language); - } -} - void DBusInputContextConnection::sendActivationLostEvent() { diff --git a/connection/dbusinputcontextconnection.h b/connection/dbusinputcontextconnection.h index 115e74a5..ca1a3f81 100644 --- a/connection/dbusinputcontextconnection.h +++ b/connection/dbusinputcontextconnection.h @@ -51,7 +51,6 @@ class DBusInputContextConnection : public MInputContextConnection, const QKeySequence &sequence); virtual void setSelection(int start, int length); virtual QString selection(bool &valid); - virtual void setLanguage(const QString &language); virtual void sendActivationLostEvent(); virtual void updateInputMethodArea(const QRegion ®ion); virtual void notifyExtendedAttributeChanged(int id, @@ -94,8 +93,6 @@ private Q_SLOTS: QHash mConnectionNumbers; QHash mProxys; QHash mConnections; - - QString lastLanguage; }; #endif // DBUSINPUTCONTEXTCONNECTION_H diff --git a/connection/mimserverconnection.h b/connection/mimserverconnection.h index abf54184..ad16d536 100644 --- a/connection/mimserverconnection.h +++ b/connection/mimserverconnection.h @@ -164,13 +164,6 @@ class MImServerConnection : public QObject */ Q_SIGNAL void getSelection(QString &selection, bool &valid) const; - /*! - * \brief Updates current language of active input method in input context. - * \param language ICU format locale ID string - * \sa QInputContext::language() - */ - Q_SIGNAL void setLanguage(const QString &language); - /*! *\brief Informs application that input method server has changed the \a attribute of the \a targetItem * in the attribute extension \a target which has unique \a id to \a value. diff --git a/connection/minputcontextconnection.cpp b/connection/minputcontextconnection.cpp index 403d2950..522990b0 100644 --- a/connection/minputcontextconnection.cpp +++ b/connection/minputcontextconnection.cpp @@ -507,11 +507,6 @@ QString MInputContextConnection::selection(bool &valid) return QString(); } -void MInputContextConnection::setLanguage(const QString &language) -{ - Q_UNUSED(language); -} - void MInputContextConnection::sendActivationLostEvent() {} diff --git a/connection/minputcontextconnection.h b/connection/minputcontextconnection.h index 37300af9..852743f6 100644 --- a/connection/minputcontextconnection.h +++ b/connection/minputcontextconnection.h @@ -207,12 +207,6 @@ class MInputContextConnection: public QObject */ virtual QString selection(bool &valid); - /*! - * \brief Sets current language of active input method. - * \param language ICU format locale ID string - */ - virtual void setLanguage(const QString &language); - virtual void sendActivationLostEvent(); QVariant inputMethodQuery(Qt::InputMethodQuery query, const QVariant &argument) const; diff --git a/connection/waylandinputmethodconnection.cpp b/connection/waylandinputmethodconnection.cpp index 25e6fbfa..eee78a42 100644 --- a/connection/waylandinputmethodconnection.cpp +++ b/connection/waylandinputmethodconnection.cpp @@ -448,18 +448,6 @@ QString WaylandInputMethodConnection::selection(bool &valid) return context ? context->selection() : QString(); } -void WaylandInputMethodConnection::setLanguage(const QString &language) -{ - Q_D(WaylandInputMethodConnection); - - qCDebug(lcWaylandConnection) << Q_FUNC_INFO; - - if (!d->context()) - return; - - d->context()->language(d->context()->serial(), language); -} - void WaylandInputMethodConnection::setSelection(int start, int length) { Q_D (WaylandInputMethodConnection); diff --git a/connection/waylandinputmethodconnection.h b/connection/waylandinputmethodconnection.h index d436be4b..35c78372 100644 --- a/connection/waylandinputmethodconnection.h +++ b/connection/waylandinputmethodconnection.h @@ -51,7 +51,6 @@ class WaylandInputMethodConnection : public MInputContextConnection virtual void setSelection(int start, int length); virtual QString selection(bool &valid); - virtual void setLanguage(const QString &language); private: const QScopedPointer d_ptr; diff --git a/dbus_interfaces/minputmethodcontext1interface.xml b/dbus_interfaces/minputmethodcontext1interface.xml index dc0444c5..90de0b59 100644 --- a/dbus_interfaces/minputmethodcontext1interface.xml +++ b/dbus_interfaces/minputmethodcontext1interface.xml @@ -59,9 +59,6 @@ - - - diff --git a/input-context/minputcontext.cpp b/input-context/minputcontext.cpp index c300753f..eb4bcf9a 100644 --- a/input-context/minputcontext.cpp +++ b/input-context/minputcontext.cpp @@ -26,7 +26,6 @@ #include #include #include -#include #include #include #include @@ -135,9 +134,6 @@ void MInputContext::connectInputMethodServer() connect(imServer, SIGNAL(getSelection(QString&,bool&)), this, SLOT(getSelection(QString&, bool&))); - - connect(imServer, SIGNAL(setLanguage(QString)), - this, SLOT(setLanguage(QString))); } @@ -146,22 +142,6 @@ bool MInputContext::isValid() const return true; } -void MInputContext::setLanguage(const QString &language) -{ - QLocale newLocale(language); - Qt::LayoutDirection oldDirection = inputDirection(); - - if (newLocale != inputLocale) { - inputLocale = newLocale; - emitLocaleChanged(); - } - - Qt::LayoutDirection newDirection = inputDirection(); - if (newDirection != oldDirection) { - emitInputDirectionChanged(newDirection); - } -} - void MInputContext::reset() { if (composeInputContext) composeInputContext->reset(); @@ -403,16 +383,6 @@ bool MInputContext::isInputPanelVisible() const return !keyboardRectangle.isEmpty(); } -QLocale MInputContext::locale() const -{ - return inputLocale; -} - -Qt::LayoutDirection MInputContext::inputDirection() const -{ - return inputLocale.textDirection(); -} - void MInputContext::sendHideInputMethod() { imServer->hideInputMethod(); diff --git a/input-context/minputcontext.h b/input-context/minputcontext.h index 5ba219af..4cd97e3a 100644 --- a/input-context/minputcontext.h +++ b/input-context/minputcontext.h @@ -55,8 +55,6 @@ class MInputContext : public QPlatformInputContext virtual void showInputPanel(); virtual void hideInputPanel(); virtual bool isInputPanelVisible() const; - virtual QLocale locale() const; - virtual Qt::LayoutDirection inputDirection() const; virtual void setFocusObject(QObject *object); QString preeditString(); @@ -83,7 +81,6 @@ public Q_SLOTS: void setDetectableAutoRepeat(bool enabled); void setSelection(int start, int length); void getSelection(QString &selection, bool &valid) const; - void setLanguage(const QString &language); // End input method server connection slots. private Q_SLOTS: @@ -141,7 +138,6 @@ private Q_SLOTS: QString preedit; int preeditCursorPos; bool redirectKeys; // redirect all hw key events to the input method or not - QLocale inputLocale; bool currentFocusAcceptsInput; QPlatformInputContext *composeInputContext; }; diff --git a/src/maliit/plugins/abstractinputmethodhost.cpp b/src/maliit/plugins/abstractinputmethodhost.cpp index 8b615cc2..c3c25530 100644 --- a/src/maliit/plugins/abstractinputmethodhost.cpp +++ b/src/maliit/plugins/abstractinputmethodhost.cpp @@ -54,7 +54,3 @@ MAbstractInputMethodHost::surroundingSubViewDescriptions(Maliit::HandlerState /* { return QList(); } - -void MAbstractInputMethodHost::setLanguage(const QString &/*language*/) -{ -} diff --git a/src/maliit/plugins/abstractinputmethodhost.h b/src/maliit/plugins/abstractinputmethodhost.h index 29d7b069..bf4d8660 100644 --- a/src/maliit/plugins/abstractinputmethodhost.h +++ b/src/maliit/plugins/abstractinputmethodhost.h @@ -281,14 +281,6 @@ public Q_SLOTS: */ virtual QList surroundingSubViewDescriptions(Maliit::HandlerState state) const; - /*! - * \brief Sets current input method language. - * \param language ICU format locale ID string - * - * This can be used as a hint to determine text direction in input fields, for example. - */ - virtual void setLanguage(const QString &language); - private: Q_DISABLE_COPY(MAbstractInputMethodHost) Q_DECLARE_PRIVATE(MAbstractInputMethodHost) diff --git a/src/maliit/standaloneinputmethodhost.cpp b/src/maliit/standaloneinputmethodhost.cpp index 4286fe0f..ef75bb86 100644 --- a/src/maliit/standaloneinputmethodhost.cpp +++ b/src/maliit/standaloneinputmethodhost.cpp @@ -30,11 +30,6 @@ bool StandaloneInputMethodHost::hiddenText(bool &valid) return mConnection->hiddenText(valid); } -void StandaloneInputMethodHost::setLanguage(const QString &language) -{ - mConnection->setLanguage(language); -} - int StandaloneInputMethodHost::contentType(bool &valid) { return mConnection->contentType(valid); diff --git a/src/maliit/standaloneinputmethodhost.h b/src/maliit/standaloneinputmethodhost.h index a9042303..22dfe9ad 100644 --- a/src/maliit/standaloneinputmethodhost.h +++ b/src/maliit/standaloneinputmethodhost.h @@ -59,7 +59,6 @@ class StandaloneInputMethodHost : public MAbstractInputMethodHost void setOrientationAngleLocked(bool lock) override; QList pluginDescriptions(Maliit::HandlerState state) const override; bool hiddenText(bool &valid) override; - void setLanguage(const QString &language) override; QVariant inputMethodQuery(Qt::InputMethodQuery query, const QVariant &argument) const override; private: MInputContextConnection *mConnection; diff --git a/src/minputmethodhost.cpp b/src/minputmethodhost.cpp index a4a79625..ed28e7db 100644 --- a/src/minputmethodhost.cpp +++ b/src/minputmethodhost.cpp @@ -223,13 +223,6 @@ MInputMethodHost::surroundingSubViewDescriptions(Maliit::HandlerState state) con return pluginManager->surroundingSubViewDescriptions(state); } -void MInputMethodHost::setLanguage(const QString &language) -{ - if (enabled) { - connection->setLanguage(language); - } -} - void MInputMethodHost::setOrientationAngleLocked(bool) { // NOT implemented. diff --git a/src/minputmethodhost.h b/src/minputmethodhost.h index f844b54e..29b5aa45 100644 --- a/src/minputmethodhost.h +++ b/src/minputmethodhost.h @@ -92,7 +92,6 @@ class MInputMethodHost: public MAbstractInputMethodHost virtual QList pluginDescriptions(Maliit::HandlerState state) const; virtual int preeditClickPos(bool &valid) const; virtual QList surroundingSubViewDescriptions(Maliit::HandlerState state) const; - virtual void setLanguage(const QString &language); //! Only empty implementation provided. virtual void setOrientationAngleLocked(bool lock); From 177ad9eaa8d96a5b5373149909fb838fa705e5cf Mon Sep 17 00:00:00 2001 From: Rodney Dawes Date: Tue, 17 May 2022 17:06:23 -0400 Subject: [PATCH 03/13] Remove MaliitSettingsEntry usage and settingdata.{cpp,h} --- CMakeLists.txt | 6 +- common/maliit/namespace.h | 19 --- common/maliit/settingdata.cpp | 141 --------------------- common/maliit/settingdata.h | 49 ------- connection/dbuscustomarguments.cpp | 2 +- connection/dbusserverconnection.cpp | 1 - src/mimpluginmanager.cpp | 1 - src/mimpluginmanager_p.h | 1 - src/msharedattributeextensionmanager.cpp | 6 +- src/msharedattributeextensionmanager.h | 2 - tests/dummyimplugin3/dummyinputmethod3.cpp | 5 - 11 files changed, 5 insertions(+), 228 deletions(-) delete mode 100644 common/maliit/settingdata.cpp delete mode 100644 common/maliit/settingdata.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 9b5fc96b..c3d022a1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -56,9 +56,7 @@ include_directories(src common) add_library(maliit-common STATIC common/maliit/namespace.h - common/maliit/namespaceinternal.h - common/maliit/settingdata.cpp - common/maliit/settingdata.h) + common/maliit/namespaceinternal.h) target_link_libraries(maliit-common Qt5::Core) target_include_directories(maliit-common PUBLIC common) @@ -91,7 +89,7 @@ if(enable-wayland) endif() set_source_files_properties(dbus_interfaces/minputmethodcontext1interface.xml dbus_interfaces/minputmethodserver1interface.xml - PROPERTIES INCLUDE maliit/settingdata.h) + PROPERTIES INCLUDE maliit/namespace.h) qt5_add_dbus_adaptor(CONNECTION_SOURCES dbus_interfaces/minputmethodcontext1interface.xml dbusserverconnection.h DBusServerConnection) qt5_add_dbus_adaptor(CONNECTION_SOURCES dbus_interfaces/minputmethodserver1interface.xml dbusinputcontextconnection.h DBusInputContextConnection) diff --git a/common/maliit/namespace.h b/common/maliit/namespace.h index 2e47b176..6fc44e5c 100644 --- a/common/maliit/namespace.h +++ b/common/maliit/namespace.h @@ -150,25 +150,6 @@ namespace Maliit { StringListType = 4, IntListType = 5 }; - - namespace SettingEntryAttributes - { - //! Name of setting entry attribute which holds the list of values that can be assigned to the entry. - //! \sa Maliit::SettingsEntry - const char* const valueDomain = "valueDomain"; - //! Name of setting entry attribute which holds the descriptions for the values in valueDomain. - //! \sa Maliit::SettingsEntry - const char* const valueDomainDescriptions = "valueDomainDescriptions"; - //! Name of setting entry attribute which holds the minimum valid value (inclusive) for an integer property. - //! \sa Maliit::SettingsEntry - const char* const valueRangeMin = "valueRangeMin"; - //! Name of setting entry attribute which holds the maximum valid value (inclusive) for an integer property. - //! \sa Maliit::SettingsEntry - const char* const valueRangeMax = "valueRangeMax"; - //! Name of setting entry attribute which holds the default value for a setting entry. - //! \sa Maliit::SettingsEntry - const char* const defaultValue = "defaultValue"; - } } Q_DECLARE_METATYPE(Maliit::TextContentType) diff --git a/common/maliit/settingdata.cpp b/common/maliit/settingdata.cpp deleted file mode 100644 index 5be6b2e8..00000000 --- a/common/maliit/settingdata.cpp +++ /dev/null @@ -1,141 +0,0 @@ -/* * This file is part of Maliit framework * - * - * Copyright (C) 2012 Mattia Barbon - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License version 2.1 as published by the Free Software Foundation - * and appearing in the file LICENSE.LGPL included in the packaging - * of this file. - */ - -#include "maliit/settingdata.h" - -namespace -{ - bool checkValueDomain(const QVariant &value, const QVariant &domain) - { - if (!domain.isValid()) - return true; - if (!domain.canConvert(QVariant::List)) - return false; - - QVariantList domain_values = domain.toList(); - - return domain_values.contains(value); - } - - bool checkValueRange(const QVariant &value, const QVariant &range_min, const QVariant &range_max) - { - if (!range_min.isValid() && !range_max.isValid()) - return true; - - if (range_min.isValid()) { - if (!range_min.canConvert(QVariant::Int)) - return false; - if (range_min.toInt() > value.toInt()) - return false; - } - - if (range_max.isValid()) { - if (!range_max.canConvert(QVariant::Int)) - return false; - if (range_max.toInt() < value.toInt()) - return false; - } - - return true; - } - - bool checkValueDomain(const QVariantList &values, const QVariant &domain) - { - if (!domain.isValid()) - return true; - if (!domain.canConvert(QVariant::List)) - return false; - - const QVariantList &domain_values = domain.toList(); - - Q_FOREACH (const QVariant &v, values) - if (!domain_values.contains(v)) - return false; - - return true; - } - - bool checkValueRange(const QVariantList &values, const QVariant &range_min, const QVariant &range_max) - { - if (!range_min.isValid() && !range_max.isValid()) - return true; - - Q_FOREACH (const QVariant &v, values) - if (!checkValueRange(v, range_min, range_max)) - return false; - - return true; - } - - bool checkIntList(const QVariant &value) - { - if (!value.canConvert()) - return false; - - const QVariantList &values = value.toList(); - - Q_FOREACH (const QVariant &v, values) - { - QVariant copy = v; - - if (!v.canConvert() || !copy.convert(QVariant::Int)) - return false; - } - - return true; - } -} - -bool validateSettingValue(Maliit::SettingEntryType type, const QVariantMap attributes, const QVariant &value) -{ - QVariant domain = attributes[Maliit::SettingEntryAttributes::valueDomain]; - QVariant range_min = attributes[Maliit::SettingEntryAttributes::valueRangeMin]; - QVariant range_max = attributes[Maliit::SettingEntryAttributes::valueRangeMax]; - QVariant copy = value; - - switch (type) - { - case Maliit::StringType: - if (!value.canConvert()) - return false; - if (!checkValueDomain(value, domain)) - return false; - break; - case Maliit::IntType: - if (!value.canConvert() || !copy.convert(QVariant::Int)) - return false; - if (!checkValueDomain(value, domain)) - return false; - if (!checkValueRange(value, range_min, range_max)) - return false; - break; - case Maliit::BoolType: - if (!value.canConvert()) - return false; - break; - case Maliit::StringListType: - if (!value.canConvert()) - return false; - if (!checkValueDomain(value.toList(), domain)) - return false; - break; - case Maliit::IntListType: - if (!checkIntList(value)) - return false; - if (!checkValueDomain(value.toList(), domain)) - return false; - if (!checkValueRange(value.toList(), range_min, range_max)) - return false; - break; - } - - return true; -} diff --git a/common/maliit/settingdata.h b/common/maliit/settingdata.h deleted file mode 100644 index 4fbc6daf..00000000 --- a/common/maliit/settingdata.h +++ /dev/null @@ -1,49 +0,0 @@ -/* * This file is part of Maliit framework * - * - * Copyright (C) 2012 Mattia Barbon - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License version 2.1 as published by the Free Software Foundation - * and appearing in the file LICENSE.LGPL included in the packaging - * of this file. - */ - -#ifndef MALIIT_SETTINGDATA_H -#define MALIIT_SETTINGDATA_H - -#include - -#include -#include -#include - - -/*! - * \brief Single configuration entry for Maliit input method plugin - * - * \sa Maliit::SettingsEntry - */ -struct MImPluginSettingsEntry -{ - //! Human-readable description - QString description; - //! The attribute extension key attribute for this entry - QString extension_key; - //! Entry value type - Maliit::SettingEntryType type; - //! Current value for the configuration entry - QVariant value; - //! Attributes, including domain values and descriptions - QVariantMap attributes; -}; - - -/*! - * \brief Validate the value for a plugin setting entry - */ -bool validateSettingValue(Maliit::SettingEntryType type, const QVariantMap attributes, const QVariant &value); - -Q_DECLARE_METATYPE(MImPluginSettingsEntry) - -#endif diff --git a/connection/dbuscustomarguments.cpp b/connection/dbuscustomarguments.cpp index b34680f7..21c99089 100644 --- a/connection/dbuscustomarguments.cpp +++ b/connection/dbuscustomarguments.cpp @@ -12,7 +12,7 @@ #include "dbuscustomarguments.h" -#include +#include #include diff --git a/connection/dbusserverconnection.cpp b/connection/dbusserverconnection.cpp index 1991c149..7def010e 100644 --- a/connection/dbusserverconnection.cpp +++ b/connection/dbusserverconnection.cpp @@ -14,7 +14,6 @@ #include "dbusserverconnection.h" #include -#include #include "minputmethodcontext1interfaceadaptor.h" #include "minputmethodserver1interface_interface.h" diff --git a/src/mimpluginmanager.cpp b/src/mimpluginmanager.cpp index 98dc5a61..997ea567 100644 --- a/src/mimpluginmanager.cpp +++ b/src/mimpluginmanager.cpp @@ -24,7 +24,6 @@ #include #include "mimsubviewoverride.h" #include "maliit/namespaceinternal.h" -#include #include "windowgroup.h" #include "logging.h" diff --git a/src/mimpluginmanager_p.h b/src/mimpluginmanager_p.h index eb79d24a..90270c04 100644 --- a/src/mimpluginmanager_p.h +++ b/src/mimpluginmanager_p.h @@ -21,7 +21,6 @@ #include "mimonscreenplugins.h" #include "mimsettings.h" #include "mimhwkeyboardtracker.h" -#include #include "windowgroup.h" #include "abstractplatform.h" diff --git a/src/msharedattributeextensionmanager.cpp b/src/msharedattributeextensionmanager.cpp index 1c589570..8e3a6ab1 100644 --- a/src/msharedattributeextensionmanager.cpp +++ b/src/msharedattributeextensionmanager.cpp @@ -9,10 +9,11 @@ * of this file. */ - #include "msharedattributeextensionmanager.h" #include "mimsettings.h" +#include + struct MSharedAttributeExtensionManagerPluginSetting { MSharedAttributeExtensionManagerPluginSetting(const QString &key, Maliit::SettingEntryType type, QVariantMap attributes) : @@ -76,9 +77,6 @@ void MSharedAttributeExtensionManager::handleExtendedAttributeUpdate(unsigned in if (it == sharedAttributeExtensions.end()) return; - // TODO error notification - if (!validateSettingValue(it->data()->type, it->data()->attributes, value)) - return; it->data()->setting.set(value); } diff --git a/src/msharedattributeextensionmanager.h b/src/msharedattributeextensionmanager.h index 047ac172..2f95cdb4 100644 --- a/src/msharedattributeextensionmanager.h +++ b/src/msharedattributeextensionmanager.h @@ -13,8 +13,6 @@ #ifndef MSHAREDATTRIBUTEEXTENSIONMANAGER_H #define MSHAREDATTRIBUTEEXTENSIONMANAGER_H -#include - #include #include #include diff --git a/tests/dummyimplugin3/dummyinputmethod3.cpp b/tests/dummyimplugin3/dummyinputmethod3.cpp index 803f36bf..9aeab56b 100644 --- a/tests/dummyimplugin3/dummyinputmethod3.cpp +++ b/tests/dummyimplugin3/dummyinputmethod3.cpp @@ -26,11 +26,6 @@ DummyInputMethod3::DummyInputMethod3(MAbstractInputMethodHost *host) addSubView("fr_fr", "fr_fr"); activeSView = "dummyim3sv1"; - - // Register setting - QVariantMap settingAttributes; - - settingAttributes[Maliit::SettingEntryAttributes::defaultValue] = "Test"; } void DummyInputMethod3::setState(const QSet &state) From b9069a2d858e104bbf5dc37a2ae47ae1ec961246 Mon Sep 17 00:00:00 2001 From: Rodney Dawes Date: Wed, 18 May 2022 17:29:07 -0400 Subject: [PATCH 04/13] Remove SettingEntryType --- common/maliit/namespace.h | 9 --------- src/msharedattributeextensionmanager.cpp | 4 +--- 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/common/maliit/namespace.h b/common/maliit/namespace.h index 6fc44e5c..a406b67e 100644 --- a/common/maliit/namespace.h +++ b/common/maliit/namespace.h @@ -141,15 +141,6 @@ namespace Maliit { //! \sa Maliit::VisualizationPriorityQuery const char* const suppressInputMethod = "maliit-suppress-input-method"; } - - enum SettingEntryType - { - StringType = 1, - IntType = 2, - BoolType = 3, - StringListType = 4, - IntListType = 5 - }; } Q_DECLARE_METATYPE(Maliit::TextContentType) diff --git a/src/msharedattributeextensionmanager.cpp b/src/msharedattributeextensionmanager.cpp index 8e3a6ab1..edfdd53c 100644 --- a/src/msharedattributeextensionmanager.cpp +++ b/src/msharedattributeextensionmanager.cpp @@ -16,15 +16,13 @@ struct MSharedAttributeExtensionManagerPluginSetting { - MSharedAttributeExtensionManagerPluginSetting(const QString &key, Maliit::SettingEntryType type, QVariantMap attributes) : + MSharedAttributeExtensionManagerPluginSetting(const QString &key, QVariantMap attributes) : setting(key), - type(type), attributes(attributes) { } MImSettings setting; - Maliit::SettingEntryType type; QVariantMap attributes; }; From 6ce3506559b54bc1e7a3bba4932d4d31967e03be Mon Sep 17 00:00:00 2001 From: Rodney Dawes Date: Tue, 24 May 2022 14:51:39 -0400 Subject: [PATCH 05/13] Remove toolbar API and docs --- doc/src/extensions.dox | 3 - doc/src/internals.dox | 26 --- doc/src/mainpage.dox | 1 - doc/src/toolbarxml.dox | 158 ------------------ input-context/minputcontext.cpp | 2 - src/mattributeextensionmanager.cpp | 35 +--- src/mattributeextensionmanager.h | 9 +- src/mimpluginmanager.cpp | 55 ------ src/mimpluginmanager.h | 6 - src/mimpluginmanager_p.h | 2 - .../toolbar1.xml | 51 ------ .../toolbar2.xml | 33 ---- .../ut_mattributeextensionmanager.cpp | 9 - tests/ut_mimpluginmanager/toolbar1.xml | 51 ------ tests/ut_mimpluginmanager/toolbar2.xml | 31 ---- .../ut_mimpluginmanager.cpp | 7 - 16 files changed, 2 insertions(+), 477 deletions(-) delete mode 100644 doc/src/toolbarxml.dox delete mode 100644 tests/ut_mattributeextensionmanager/toolbar1.xml delete mode 100644 tests/ut_mattributeextensionmanager/toolbar2.xml delete mode 100644 tests/ut_mimpluginmanager/toolbar1.xml delete mode 100644 tests/ut_mimpluginmanager/toolbar2.xml diff --git a/doc/src/extensions.dox b/doc/src/extensions.dox index 9d1d1b46..db077822 100644 --- a/doc/src/extensions.dox +++ b/doc/src/extensions.dox @@ -23,9 +23,6 @@ In normal mode input method sends the inputted text using a standard pre-edit an In direct mode input method crafts a fake QKeyEvent and sends it to the input context. There, if the input method does not want to compose the event, it is forwarded to the application. -\subsection InputMethodToolbarQuery M::InputMethodToolbarQuery -This query returns a QString of input method toolbar name to be shown. Input method loads the named toolbar and displays that in it's UI. - \section IMState MInputMethodState This class provides additional information which QInputContext does not provide. The widget which needs these information can connect to the available signal and slots. The more accurate description will be maintained in the MInputMethodState class documentation. However here is a short version. diff --git a/doc/src/internals.dox b/doc/src/internals.dox index 6ccfc9cb..e88a1fe7 100644 --- a/doc/src/internals.dox +++ b/doc/src/internals.dox @@ -98,14 +98,6 @@ If current input method mode is M::InputMethodModeDirect, then the input method \subsection Pre_edit_injection Pre-edit injection MTextEdit widget requires that if a word is clicked then it needs to be turned into a pre-edit, so it can be changed into another word with error correction feature. When this happens, the clicked word is removed and the widget constructs a MPreeditInjection event and sends it to input context. If the event is accepted, e.g. if the error correction is enabled, then the incoming word enclosed in the event is treated as pre-edit. In MInputContext side, upon receiving this event, a QInputMethodEvent will be constructed with the word as a new pre-edit string and sent to the widget. MInputContext will then call im::setPreedit() RPC function to inform the input method about the new pre-edit string. Upon receiving the new pre-edit string, the input method will decide appropriate styling for the pre-edit and call app::sendPreeditString() RPC function. Please note that pre-edit becomes truly active only after input method has called app::sendPreeditString() RPC function. This means that update() will be called only after app::sendPreeditString() RPC function has been called and therefore input method will not know the true state of the widget (e.g. cursor position and surrounding text) before. -\subsection Copy_and_paste Copy and paste - -MInputContext connects itself to widget's signal which called "copyAvailable(bool)" if exists. Whenever this signal is emitted, MInputContext calls im::setCopyPasteButton RPC function [MInputContextDBusConnection::setCopyPasteState?] to update the visibility of Copy/Paste button in the input method's toolbar. If system clipboard has text content, the Paste button is shown instead of Copy button. - -When the Copy button is clicked, input method calls app::copy RPC function. Upon receiving this call, MInputContext calls widget's "copy" function if available, otherwise it just sends ctrl-c combination key event to the widget. - -When the Paste button is clicked, input method calls app::paste RPC function. Upon receiving this call, MInputContext calls widget's "paste" function if available, otherwise it just sends ctrl-v combination key event to the widget. - \subsection Setting Setting \subsubsection Input_mode Input mode The framework supports two modes: M::InputMethodModeNormal and M::InputMethodModeDirect [MInputContextDBusConnection::inputMethodMode?]. If the widget wants direct key event instead of getting the text using pre-edit/commit string, it can set the mode to M::InputMethodModeDirect, otherwise, the M::InputMethodModeNormal which is the default value will be used at all times. @@ -146,22 +138,4 @@ If error correction feature is enabled and mouse clicked is happening on a pre-e \subsection Text_entry_types Text entry types The widget can determine its content type. It returns the content type when asked with M::ContentTypeQuery in its inputMethodQuery method. -\subsection Toolbar Toolbar - -The text entry widget can ask the input method to put a custom widget into a toolbar (which will be part of the input method UI). This widget, called "toolbar widget", is essentially a declarative widget written in XML. It is compiled into into a widget by the plugin during the loading of the plugin. Details can be found in the Input Method Toolbar. Toolbar widgets will appear in the toolbar only when instructed by the text entry widget. One use case is rich text editing. The rich text entry could show Bold, Italic, Underline and other buttons to control the rich text editing in the toolbar. - -The input method shows/hides the toolbar widgets upon receiving events as defined in the toolbar widget's XML data. - -When an event takes place on a toolbar widget, the input method sends a sequence of actions defined as defined in the XML data. The list below describes the actions and how it is handled by input method: -- sendKeySequence: input method constructs key events and process it as described above -- sendString: input method sends the word described as commit string -- copy: input method asks the widget to copy selected text into clipboard -- paste: input method asks the widget to paste from clipboard -- sendCommand: input method passes the defined command to app::toolbarWidgetCommand RPC function - -The widget can change the attributes of an item in toolbar. Except the NAME attribute, all others attributes can be changed by the widget in runtime. To change an attribute, a widget call im::setToolbarItemAttribute() RPC function. - -The widget can also get the attribute on an item in toolbar by calling im::toolbarItemAttribute() RPC function. -\sa toolbar - */ diff --git a/doc/src/mainpage.dox b/doc/src/mainpage.dox index 71e71aad..40aab606 100644 --- a/doc/src/mainpage.dox +++ b/doc/src/mainpage.dox @@ -51,7 +51,6 @@ The following base classes are needed to implement an input method UI plugin: - Extensions to Qt - Plugin System - Feature Internals -- Toolbar Widget XML Specification @subsection tutorial Tutorial - How to implement a plugin diff --git a/doc/src/toolbarxml.dox b/doc/src/toolbarxml.dox deleted file mode 100644 index e296a6bf..00000000 --- a/doc/src/toolbarxml.dox +++ /dev/null @@ -1,158 +0,0 @@ -/*! \page toolbarxml Toolbar Widget XML Specification -Version: 0.1 - -\section Overview -This document describes the XML specification of the toolbar widget. - -\sa MToolbarData - -\section Tags -\subsection INPUT-METHOD -Root tag, it contains information which should be used by input method plugin. -The VERSION attribute defines version of this specification. Current version is 1. -Warning: you need to specify version number explicitly, otherwise parser may assume wrong version number and then parsing will fail. -The VISIBLE attribute defines toolbar's visibility. Toolbar is visible by default, but you could hide it by setting VISIBLE to false. -Warning: normal application should not use this attribute. -The REFUSE attribute enumerates names of standard items which should not be added to your toolbar. Names should be separated by commas without spaces. See also "Standard toolbar items". - -\subsection TOOLBAR -It contains the definition for all items in the toolbar. -TOOLBAR tag could be used as root tag for backward compatibility. -This tag have same attributes as INPUT-METHOD. - -\subsection ITEMS -This tag contains definitions of all items which will be placed into layouts. - -\subsubsection BUTTON -This tag will be constructed as MButton. -The NAME attribute is used as a reference in the toolbar system. -All buttons with the same NAME share their state. If two buttons have the same name then their state is defined by first one and then overriden (completely or partially) by second one. This feature allows to have consistent button state with different device orientation. All names starting with underscore are reserved for Input Method Framework. -Warning: it is not recommended to create more than one button with the same name inside one layout. -The GROUP attribute defines the group this button belongs to. -The SHOWON attribute tells when the button is displayed. If the value is "selectedtext", it will be only displayed when there is a selected text. If the value is "always" then it is always displayed. -Similar rule applies with HIDEON attribute, except that there is no "always" value. -Buttons can be aligned within toolbar by using the ALIGNMENT attribute. By default, buttons are center-aligned. Possible other alignments are left or right. -The ICON attribute holds the icon file name (absolute file name). The icon will be displayed in the center of the button. -The SIZE attribute holds the icon size percentage. The icon will be resized according this attribute and the button size. -The ICON_ID attribute holds the icon logical id to be displayed on button. ICON_ID has higher priority than ICON, so if both ICON and ICON_ID are specified, ICON_ID will be used. Note: only the ICON_ID of the icons loaded by meegotouch theme will be used. -The TEXT attribute holds the text and TEXT_ID holds the logical id of the text. -The TOGGLE attribute defines the type of the button whether it is a toggle button or not, by default the value is false. -If the TOGGLE attribute is true, the PRESSED attribute holds the button state whether the button is pressed or not. -The HIGHLIGHTED attribute selects which background image should be used. -The ENABLED attribute holds whether the button is enabled. Default value is true. If it is set to false, the button will be disabled. -The VISIBLE attribute defines the button's visibility. Normally, application does not need to specify this attribute. The button is visible by default, but application could hide it by setting VISIBLE to false. This attribute will override the SHOWON and HIDEON. -Text inside button is always center-aligned. - -\subsubsection LABEL -This tag will be constructed as MLabel. -LABEL tag could have following attributes: NAME, GROUP, VISIBLE, SHOWON, HIDEON, ALIGMENT, TEXT and TEXT_ID. -Every attribute has the same meaning as for BUTTON tag. -Text inside labels can be horizontally aligned by using the CONTENT-ALIGNMENT attribute. By default, label text is center-aligned. Possible other content alignments are left or right. - -\subsubsubsection ACTIONS -This tag holds a sequence of actions defined within. - -\subsubsubsubsection SENDKEYSEQUENCE -The tag's value holds the key sequence to be sent in the format which is understood by QKeySequence to the text entry widget. - -\subsubsubsubsection SENDSTRING -The tag's value holds the string to be sent to the text entry widget as committed text. - -\subsubsubsubsection SENDCOMMAND -The tag's value holds the command to be sent to the text entry widget. The command would be widget specific. - -\subsubsubsubsection SHOWGROUP -This tag defines that the action is to show the named group of buttons. - -\subsubsubsubsection HIDEGROUP -This tag defines that the action is to hide the named group of buttons. - -\subsubsubsubsection COPY -This tag defines that the action is to copy selected text. - -\subsubsubsubsection PASTE -This tag defines that the action is to paste from clipboard. - -\subsubsubsubsection CLOSE -This tag defines that the action is to close keyboard and removes focus from active text entry. - -\subsection Layout - -Layout describes the actual toolbar layout for a given screen orientation. If the layout doesn't have a portrait variant, the software shall use the landscape variant when the device is in portrait orientation. Each layout contains one row only. - -\subsubsection Row - -This tag defines one row in toolbar. -It is not recommended to create more than one row for landscape orientation. -Row may not be empty. -Warning: this tag is deprecated and will be removed soon, because toolbar should have one row only. - -\subsubsection Item - -This tag defines which item should be placed into toolbar. -NAME attribute selects correspondig item (button or label) which is defined in the Items section. - -\section Standard toolbar items -Button "_close" closes keyboard and removes focus from active text entry. This button is right aligned. -Button "_copypaste" copies selected text (if any) or pastes current clipboard content. This button is left aligned. -Warning: you can use REFUSE to remove standard toolbar items. But you should not change the attributes of standard toolbar items. - -\section DTD -\code - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -]> -\endcode -*/ diff --git a/input-context/minputcontext.cpp b/input-context/minputcontext.cpp index eb4bcf9a..31467baa 100644 --- a/input-context/minputcontext.cpp +++ b/input-context/minputcontext.cpp @@ -743,8 +743,6 @@ QMap MInputContext::getStateInformation() const } } - stateInformation["toolbarId"] = 0; // Global extension id. And bad state parameter name for it. - return stateInformation; } diff --git a/src/mattributeextensionmanager.cpp b/src/mattributeextensionmanager.cpp index 5b25793e..51f97ddd 100644 --- a/src/mattributeextensionmanager.cpp +++ b/src/mattributeextensionmanager.cpp @@ -27,11 +27,8 @@ namespace { const char * const PreferredDomainSettingName(MALIIT_CONFIG_ROOT"preferred_domain"); const char * const DomainItemName("_domain"); const char * const KeysExtensionString("/keys"); - const char * const ToolbarExtensionString("/toolbar"); const char * const GlobalExtensionString("/"); - const char * const ToolbarIdAttribute = "toolbarId"; - const char * const ToolbarAttribute = "toolbar"; const char * const FocusStateAttribute = "focusState"; } @@ -120,15 +117,6 @@ void MAttributeExtensionManager::unregisterAttributeExtension(const MAttributeEx attributeExtensions.remove(id); } -void MAttributeExtensionManager::setToolbarItemAttribute(const MAttributeExtensionId &id, - const QString &itemName, - const QString &attribute, - const QVariant &value) -{ - setExtendedAttribute(id, ToolbarExtensionString, itemName, - attribute, value); -} - QMap > MAttributeExtensionManager::keyOverrides( const MAttributeExtensionId &id) const { @@ -250,16 +238,11 @@ void MAttributeExtensionManager::handleWidgetStateChanged(unsigned int clientId, MAttributeExtensionId newAttributeExtensionId; oldAttributeExtensionId = attributeExtensionId; - QVariant variant = newState[ToolbarIdAttribute]; - if (variant.isValid()) { - // map toolbar id from local to global - newAttributeExtensionId = MAttributeExtensionId(variant.toInt(), QString::number(clientId)); - } if (!newAttributeExtensionId.isValid()) { newAttributeExtensionId = MAttributeExtensionId::standardAttributeExtensionId(); } - variant = newState[FocusStateAttribute]; + QVariant variant = newState[FocusStateAttribute]; if (not variant.isValid()) { qCCritical(lcMaliitFw) << Q_FUNC_INFO << "Invalid focus state"; } @@ -267,22 +250,6 @@ void MAttributeExtensionManager::handleWidgetStateChanged(unsigned int clientId, // compare the toolbar id (global) if (oldAttributeExtensionId != newAttributeExtensionId) { - QString toolbarFile = newState[ToolbarAttribute].toString(); - if (!contains(newAttributeExtensionId) && !toolbarFile.isEmpty()) { - // register toolbar if toolbar manager does not contain it but - // toolbar file is not empty. This can reload the toolbar data - // if im-uiserver crashes. - // XXX: should not happen, the input context is reponsible for registering - // and resending the toolbar information on server reconnect - qCWarning(lcMaliitFw) << "Unregistered toolbar found in widget information"; - - variant = newState[ToolbarIdAttribute]; - if (variant.isValid()) { - const int toolbarLocalId = variant.toInt(); - // FIXME: brittle to call the signal handler directly like this - handleAttributeExtensionRegistered(clientId, toolbarLocalId, toolbarFile); - } - } Q_EMIT attributeExtensionIdChanged(newAttributeExtensionId); // store the new used toolbar id(global). attributeExtensionId = newAttributeExtensionId; diff --git a/src/mattributeextensionmanager.h b/src/mattributeextensionmanager.h index 9f707e7c..7f35b36e 100644 --- a/src/mattributeextensionmanager.h +++ b/src/mattributeextensionmanager.h @@ -32,8 +32,7 @@ /*! \ingroup maliitserver \brief The MAttributeExtensionManager class manager the virtual keyboard attribute extensions. - AttributeExtensionManager loads and manages not only the toolbars which are registered - by applications, but also the copy/paste button and key overrides. + AttributeExtensionManager loads and manages key overrides. */ class MAttributeExtensionManager : public QObject { @@ -64,12 +63,6 @@ class MAttributeExtensionManager : public QObject */ void unregisterAttributeExtension(const MAttributeExtensionId &id); - /*! - * \brief Sets the \a attribute for the \a item in the custom toolbar which has the unique \a id to \a value. - */ - void setToolbarItemAttribute(const MAttributeExtensionId &id, const QString &item, - const QString &attribute, const QVariant &value); - /*! *\brief Returns widget data definition for gived \a id. */ diff --git a/src/mimpluginmanager.cpp b/src/mimpluginmanager.cpp index 997ea567..5cdb735f 100644 --- a/src/mimpluginmanager.cpp +++ b/src/mimpluginmanager.cpp @@ -349,9 +349,6 @@ void MIMPluginManagerPrivate::replacePlugin(Maliit::SwitchDirection direction, if (source) { plugins[source].lastSwitchDirection = direction; } - QMap > keyOverrides = - attributeExtensionManager->keyOverrides(toolbarId); - switchedTo->setKeyOverrides(keyOverrides); if (visible) { ensureActivePluginsVisible(DontShowInputMethod); @@ -1093,13 +1090,6 @@ MIMPluginManager::MIMPluginManager(const QSharedPointer connect(d->mICConnection.data(), SIGNAL(focusChanged(WId)), this, SLOT(handleAppFocusChanged(WId))); - // Connect from MAttributeExtensionManager to our handlers - connect(d->attributeExtensionManager.data(), SIGNAL(attributeExtensionIdChanged(const MAttributeExtensionId &)), - this, SLOT(setToolbar(const MAttributeExtensionId &))); - - connect(d->attributeExtensionManager.data(), SIGNAL(keyOverrideCreated()), - this, SLOT(updateKeyOverrides())); - connect(d->attributeExtensionManager.data(), SIGNAL(globalAttributeChanged(MAttributeExtensionId,QString,QString,QVariant)), this, SLOT(onGlobalAttributeChanged(MAttributeExtensionId,QString,QString,QVariant))); @@ -1237,40 +1227,6 @@ void MIMPluginManager::setAllSubViewsEnabled(bool enable) d->onScreenPlugins.setAllSubViewsEnabled(enable); } -void MIMPluginManager::setToolbar(const MAttributeExtensionId &id) -{ - Q_D(MIMPluginManager); - - // Record MAttributeExtensionId for switch Plugin - d->toolbarId = id; - - QMap > keyOverrides = - d->attributeExtensionManager->keyOverrides(id); - - bool focusStateOk(false); - const bool focusState(d->mICConnection->focusState(focusStateOk)); - - if (!focusStateOk) { - qCCritical(lcMaliitFw) << Q_FUNC_INFO << ": focus state is invalid."; - } - - const bool mapEmpty(keyOverrides.isEmpty()); - // setKeyOverrides are not called when keyOverrides map is empty - // and no widget is focused - we do not want to update keys because either - // vkb is not visible or another input widget is focused in, so its - // extension attribute will be used in a moment. without this, some vkbs - // may have some flickering - first it could show default label and a - // fraction of second later - an overriden label. - const bool callKeyOverrides(!(!focusState && mapEmpty)); - - Q_FOREACH (Maliit::Plugins::InputMethodPlugin *plugin, d->activePlugins) { - if (callKeyOverrides) - { - d->plugins.value(plugin).inputMethod->setKeyOverrides(keyOverrides); - } - } -} - void MIMPluginManager::showActivePlugins() { Q_D(MIMPluginManager); @@ -1310,17 +1266,6 @@ void MIMPluginManager::setActiveSubView(const QString &subViewId, Maliit::Handle d->_q_setActiveSubView(subViewId, state); } -void MIMPluginManager::updateKeyOverrides() -{ - Q_D(MIMPluginManager); - QMap > keyOverrides = - d->attributeExtensionManager->keyOverrides(d->toolbarId); - - Q_FOREACH (Maliit::Plugins::InputMethodPlugin *plugin, d->activePlugins) { - d->plugins.value(plugin).inputMethod->setKeyOverrides(keyOverrides); - } -} - void MIMPluginManager::handleAppOrientationAboutToChange(int angle) { Q_FOREACH (MAbstractInputMethod *target, targets()) { diff --git a/src/mimpluginmanager.h b/src/mimpluginmanager.h index de710301..ea89737b 100644 --- a/src/mimpluginmanager.h +++ b/src/mimpluginmanager.h @@ -122,12 +122,6 @@ private Q_SLOTS: //! Update and activate input source. void updateInputSource(); - //! Set toolbar to active plugin with given \a id - void setToolbar(const MAttributeExtensionId &id); - - //! Update the key overrides for active plugin. - void updateKeyOverrides(); - void handleAppOrientationChanged(int angle); void handleAppOrientationAboutToChange(int angle); void handleAppFocusChanged(WId id); diff --git a/src/mimpluginmanager_p.h b/src/mimpluginmanager_p.h index 90270c04..c6627b20 100644 --- a/src/mimpluginmanager_p.h +++ b/src/mimpluginmanager_p.h @@ -167,8 +167,6 @@ class MIMPluginManagerPrivate typedef QMap InputSourceToNameMap; InputSourceToNameMap inputSourceToNameMap; - MAttributeExtensionId toolbarId; - MImOnScreenPlugins onScreenPlugins; MImHwKeyboardTracker hwkbTracker; diff --git a/tests/ut_mattributeextensionmanager/toolbar1.xml b/tests/ut_mattributeextensionmanager/toolbar1.xml deleted file mode 100644 index 3fc24324..00000000 --- a/tests/ut_mattributeextensionmanager/toolbar1.xml +++ /dev/null @@ -1,51 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/ut_mimpluginmanager/ut_mimpluginmanager.cpp b/tests/ut_mimpluginmanager/ut_mimpluginmanager.cpp index ef114e0f..f28ba502 100644 --- a/tests/ut_mimpluginmanager/ut_mimpluginmanager.cpp +++ b/tests/ut_mimpluginmanager/ut_mimpluginmanager.cpp @@ -47,8 +47,6 @@ namespace { const QString pluginId3 = "libdummyimplugin3.so"; const QString testDirectory = "/ut_mimpluginmanager"; - QString Toolbar1 = "/toolbar1.xml"; - QString Toolbar2 = "/toolbar2.xml"; const QStringList DefaultEnabledPlugins = QStringList() << pluginId + ":" + "dummyimsv1" @@ -87,11 +85,6 @@ class MInputContextTestConnection : public MInputContextConnection void Ut_MIMPluginManager::initTestCase() { - Toolbar1 = MaliitTestUtils::getTestDataPath() + testDirectory + Toolbar1; - QVERIFY2(QFile(Toolbar1).exists(), "toolbar1.xml does not exist"); - Toolbar2 = MaliitTestUtils::getTestDataPath() + testDirectory + Toolbar2; - QVERIFY2(QFile(Toolbar2).exists(), "toolbar2.xml does not exist"); - MImSettings::setPreferredSettingsType(MImSettings::TemporarySettings); } From cfaaec2db11ec45b45977e5033e559fc2968f899 Mon Sep 17 00:00:00 2001 From: Rodney Dawes Date: Tue, 7 Jun 2022 15:53:08 -0400 Subject: [PATCH 06/13] Remove attribute extensions API --- CMakeLists.txt | 17 -- common/maliit/namespace.h | 6 - connection/dbusinputcontextconnection.cpp | 10 - connection/dbusinputcontextconnection.h | 2 - connection/dbusserverconnection.cpp | 16 -- connection/dbusserverconnection.h | 2 - connection/mimserverconnection.cpp | 11 - connection/mimserverconnection.h | 2 - connection/minputcontextconnection.cpp | 11 - connection/minputcontextconnection.h | 17 -- connection/waylandinputmethodconnection.cpp | 2 +- .../minputmethodserver1interface.xml | 7 - doc/src/mainpage.dox | 1 - input-context/minputcontext.cpp | 3 - .../maliitattributeextensionregistry.c | 41 +-- src/maliit/plugins/attributeextension.cpp | 50 ---- src/maliit/plugins/attributeextension.h | 61 ---- src/maliit/plugins/attributeextension_p.h | 36 --- src/mattributeextensionid.cpp | 69 ----- src/mattributeextensionid.h | 71 ----- src/mattributeextensionmanager.cpp | 262 ------------------ src/mattributeextensionmanager.h | 163 ----------- src/mimpluginmanager.cpp | 67 ----- src/mimpluginmanager.h | 14 - src/mimpluginmanager_p.h | 6 - src/msharedattributeextensionmanager.cpp | 97 ------- src/msharedattributeextensionmanager.h | 76 ----- .../ft_mimpluginmanager.cpp | 1 - .../ut_mattributeextensionmanager/.gitignore | 1 - .../ut_mattributeextensionmanager.cpp | 99 ------- .../ut_mattributeextensionmanager.h | 37 --- .../ut_mimpluginmanager.cpp | 3 - .../ut_mimpluginmanagerconfig.cpp | 3 - 33 files changed, 3 insertions(+), 1261 deletions(-) delete mode 100644 src/maliit/plugins/attributeextension.cpp delete mode 100644 src/maliit/plugins/attributeextension.h delete mode 100644 src/maliit/plugins/attributeextension_p.h delete mode 100644 src/mattributeextensionid.cpp delete mode 100644 src/mattributeextensionid.h delete mode 100644 src/mattributeextensionmanager.cpp delete mode 100644 src/mattributeextensionmanager.h delete mode 100644 src/msharedattributeextensionmanager.cpp delete mode 100644 src/msharedattributeextensionmanager.h delete mode 100644 tests/ut_mattributeextensionmanager/.gitignore delete mode 100644 tests/ut_mattributeextensionmanager/ut_mattributeextensionmanager.cpp delete mode 100644 tests/ut_mattributeextensionmanager/ut_mattributeextensionmanager.h diff --git a/CMakeLists.txt b/CMakeLists.txt index c3d022a1..1a674e5e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -112,9 +112,6 @@ set(PLUGINS_SOURCES src/maliit/plugins/abstractinputmethod.h src/maliit/plugins/abstractinputmethodhost.cpp src/maliit/plugins/abstractinputmethodhost.h - src/maliit/plugins/attributeextension.cpp - src/maliit/plugins/attributeextension.h - src/maliit/plugins/attributeextension_p.h src/maliit/plugins/extensionevent.cpp src/maliit/plugins/extensionevent.h src/maliit/plugins/extensionevent_p.h @@ -149,10 +146,6 @@ set(PLUGINS_SOURCES src/abstractplatform.h src/logging.cpp src/logging.h - src/mattributeextensionid.cpp - src/mattributeextensionid.h - src/mattributeextensionmanager.cpp - src/mattributeextensionmanager.h src/mimhwkeyboardtracker.h src/mimonscreenplugins.cpp src/mimonscreenplugins.h @@ -171,8 +164,6 @@ set(PLUGINS_SOURCES src/mimsubviewoverride.h src/minputmethodhost.cpp src/minputmethodhost.h - src/msharedattributeextensionmanager.cpp - src/msharedattributeextensionmanager.h src/unknownplatform.cpp src/unknownplatform.h src/windowdata.cpp @@ -273,7 +264,6 @@ endif() add_definitions(-DMALIIT_FRAMEWORK_USE_INTERNAL_API -DMALIIT_PLUGINS_DATA_DIR="${CMAKE_INSTALL_FULL_DATADIR}/maliit/plugins" - -DMALIIT_EXTENSIONS_DIR="${CMAKE_INSTALL_FULL_DATADIR}/maliit-framework/extensions" -DMALIIT_CONFIG_ROOT="/maliit/" -DMALIIT_PLUGINS_DIR="${CMAKE_INSTALL_FULL_LIBDIR}/maliit/plugins" -DMALIIT_DEFAULT_HW_PLUGIN="libmaliit-keyboard-plugin.so" @@ -523,7 +513,6 @@ if(enable-tests) endfunction() create_test(sanitychecks) - create_test(ut_mattributeextensionmanager) create_test(ut_mimonscreenplugins) create_test(ut_mimpluginmanager ${DUMMY_PLUGINS}) create_test(ut_mimpluginmanagerconfig) @@ -561,11 +550,5 @@ if(enable-tests) DESTINATION ${CMAKE_INSTALL_LIBDIR}/maliit-framework-tests/plugins/qml/helloworld) install(TARGETS ${DUMMY_PLUGINS} DESTINATION ${CMAKE_INSTALL_LIBDIR}/maliit-framework-tests/plugins) - install(DIRECTORY tests/ut_mattributeextensionmanager/ - DESTINATION ${CMAKE_INSTALL_LIBDIR}/maliit-framework-tests/ut_mattributeextensionmanager - FILES_MATCHING PATTERN "*.xml") - install(DIRECTORY tests/ut_mimpluginmanager/ - DESTINATION ${CMAKE_INSTALL_LIBDIR}/maliit-framework-tests/ut_mimpluginmanager - FILES_MATCHING PATTERN "*.xml") endif() endif() diff --git a/common/maliit/namespace.h b/common/maliit/namespace.h index a406b67e..13e411bc 100644 --- a/common/maliit/namespace.h +++ b/common/maliit/namespace.h @@ -126,12 +126,6 @@ namespace Maliit { //! Name of property which tells whether correction is enabled. //! \sa Maliit::ImCorrectionEnabledQuery. const char* const correctionEnabledQuery = "maliit-correction-enabled"; - //! Name of property which holds ID of attribute extension. - //! \sa Maliit::InputMethodAttributeExtensionIdQuery. - const char* const attributeExtensionId = "maliit-attribute-extension-id"; - //! Name of property which holds attribute extension. - //! \sa Maliit::InputMethodAttributeExtensionQuery. - const char* const attributeExtension = "maliit-attribute-extension"; //! Name of the property which overrides localized numeric input with western numeric input. //! \sa Maliit::WesternNumericInputEnforcedQuery. const char* const westernNumericInputEnforced = "maliit-western-numeric-input-enforced"; diff --git a/connection/dbusinputcontextconnection.cpp b/connection/dbusinputcontextconnection.cpp index f4e59fad..09fb9637 100644 --- a/connection/dbusinputcontextconnection.cpp +++ b/connection/dbusinputcontextconnection.cpp @@ -335,16 +335,6 @@ void DBusInputContextConnection::processKeyEvent(int keyType, int keyCode, int m MInputContextConnection::processKeyEvent(connectionNumber(), static_cast(keyType), static_cast(keyCode), static_cast(modifiers), text, autoRepeat, count, nativeScanCode, nativeModifiers, time); } -void DBusInputContextConnection::registerAttributeExtension(int id, const QString &fileName) -{ - MInputContextConnection::registerAttributeExtension(connectionNumber(), id, fileName); -} - -void DBusInputContextConnection::unregisterAttributeExtension(int id) -{ - MInputContextConnection::unregisterAttributeExtension(connectionNumber(), id); -} - void DBusInputContextConnection::setExtendedAttribute(int id, const QString &target, const QString &targetItem, const QString &attribute, const QDBusVariant &value) { MInputContextConnection::setExtendedAttribute(connectionNumber(), id, target, targetItem, attribute, value.variant()); diff --git a/connection/dbusinputcontextconnection.h b/connection/dbusinputcontextconnection.h index ca1a3f81..992736f0 100644 --- a/connection/dbusinputcontextconnection.h +++ b/connection/dbusinputcontextconnection.h @@ -77,8 +77,6 @@ class DBusInputContextConnection : public MInputContextConnection, void appOrientationChanged(int angle); void setCopyPasteState(bool copyAvailable, bool pasteAvailable); void processKeyEvent(int keyType, int keyCode, int modifiers, const QString &text, bool autoRepeat, int count, uint nativeScanCode, uint nativeModifiers, uint time); - void registerAttributeExtension(int id, const QString &fileName); - void unregisterAttributeExtension(int id); void setExtendedAttribute(int id, const QString &target, const QString &targetItem, const QString &attribute, const QDBusVariant &value); private Q_SLOTS: diff --git a/connection/dbusserverconnection.cpp b/connection/dbusserverconnection.cpp index 7def010e..87fa4bc4 100644 --- a/connection/dbusserverconnection.cpp +++ b/connection/dbusserverconnection.cpp @@ -219,22 +219,6 @@ void DBusServerConnection::processKeyEvent(QEvent::Type keyType, Qt::Key keyCode mProxy->processKeyEvent(keyType, keyCode, modifiers, text, autoRepeat, count, nativeScanCode, nativeModifiers, time); } -void DBusServerConnection::registerAttributeExtension(int id, const QString &fileName) -{ - if (!mProxy) - return; - - mProxy->registerAttributeExtension(id, fileName); -} - -void DBusServerConnection::unregisterAttributeExtension(int id) -{ - if (!mProxy) - return; - - mProxy->unregisterAttributeExtension(id); -} - void DBusServerConnection::setExtendedAttribute(int id, const QString &target, const QString &targetItem, const QString &attribute, const QVariant &value) { diff --git a/connection/dbusserverconnection.h b/connection/dbusserverconnection.h index 61b4ed88..014c0aec 100644 --- a/connection/dbusserverconnection.h +++ b/connection/dbusserverconnection.h @@ -48,8 +48,6 @@ class DBusServerConnection : public MImServerConnection Qt::KeyboardModifiers modifiers, const QString &text, bool autoRepeat, int count, quint32 nativeScanCode, quint32 nativeModifiers, unsigned long time); - virtual void registerAttributeExtension(int id, const QString &fileName); - virtual void unregisterAttributeExtension(int id); virtual void setExtendedAttribute(int id, const QString &target, const QString &targetItem, const QString &attribute, const QVariant &value); //! reimpl end diff --git a/connection/mimserverconnection.cpp b/connection/mimserverconnection.cpp index ec00cf42..72176f23 100644 --- a/connection/mimserverconnection.cpp +++ b/connection/mimserverconnection.cpp @@ -91,17 +91,6 @@ void MImServerConnection::processKeyEvent(QEvent::Type keyType, Qt::Key keyCode, Q_UNUSED(time); } -void MImServerConnection::registerAttributeExtension(int id, const QString &fileName) -{ - Q_UNUSED(id); - Q_UNUSED(fileName); -} - -void MImServerConnection::unregisterAttributeExtension(int id) -{ - Q_UNUSED(id); -} - void MImServerConnection::setExtendedAttribute(int id, const QString &target, const QString &targetItem, const QString &attribute, const QVariant &value) { diff --git a/connection/mimserverconnection.h b/connection/mimserverconnection.h index ad16d536..fd38a9d7 100644 --- a/connection/mimserverconnection.h +++ b/connection/mimserverconnection.h @@ -45,8 +45,6 @@ class MImServerConnection : public QObject Qt::KeyboardModifiers modifiers, const QString &text, bool autoRepeat, int count, quint32 nativeScanCode, quint32 nativeModifiers, unsigned long time); - virtual void registerAttributeExtension(int id, const QString &fileName); - virtual void unregisterAttributeExtension(int id); virtual void setExtendedAttribute(int id, const QString &target, const QString &targetItem, const QString &attribute, const QVariant &value); diff --git a/connection/minputcontextconnection.cpp b/connection/minputcontextconnection.cpp index 522990b0..e06b4a65 100644 --- a/connection/minputcontextconnection.cpp +++ b/connection/minputcontextconnection.cpp @@ -329,17 +329,6 @@ void MInputContextConnection::processKeyEvent( nativeScanCode, nativeModifiers, time); } -void MInputContextConnection::registerAttributeExtension(unsigned int connectionId, int id, - const QString &attributeExtension) -{ - Q_EMIT attributeExtensionRegistered(connectionId, id, attributeExtension); -} - -void MInputContextConnection::unregisterAttributeExtension(unsigned int connectionId, int id) -{ - Q_EMIT attributeExtensionUnregistered(connectionId, id); -} - void MInputContextConnection::setExtendedAttribute( unsigned int connectionId, int id, const QString &target, const QString &targetName, const QString &attribute, const QVariant &value) diff --git a/connection/minputcontextconnection.h b/connection/minputcontextconnection.h index 852743f6..f2acf93e 100644 --- a/connection/minputcontextconnection.h +++ b/connection/minputcontextconnection.h @@ -25,7 +25,6 @@ QT_END_NAMESPACE class MInputContextConnectionPrivate; class MAbstractInputMethod; -class MAttributeExtensionId; /*! \internal * \ingroup maliitserver @@ -261,20 +260,6 @@ class MInputContextConnection: public QObject Qt::KeyboardModifiers modifiers, const QString &text, bool autoRepeat, int count, quint32 nativeScanCode, quint32 nativeModifiers, unsigned long time); - /*! - * \brief Register an input method attribute extension which is defined in \a fileName with the - * unique identifier \a id. - * - * The \a id should be unique, and the \a fileName is the absolute file name of the - * attribute extension. - */ - void registerAttributeExtension(unsigned int clientId, int id, const QString &fileName); - - /*! - * \brief Unregister an input method attribute extension which unique identifier is \a id. - */ - void unregisterAttributeExtension(unsigned int clientId, int id); - /*! * \brief Sets the \a attribute for the \a target in the extended attribute which has unique \a id to \a value. */ @@ -328,8 +313,6 @@ public Q_SLOTS: void widgetStateChanged(unsigned int clientId, const QMap &newState, const QMap &oldState, bool focusChanged); - void attributeExtensionRegistered(unsigned int connectionId, int id, const QString &attributeExtension); - void attributeExtensionUnregistered(unsigned int connectionId, int id); void extendedAttributeChanged(unsigned int connectionId, int id, const QString &target, const QString &targetName,const QString &attribute, const QVariant &value); diff --git a/connection/waylandinputmethodconnection.cpp b/connection/waylandinputmethodconnection.cpp index eee78a42..bef77287 100644 --- a/connection/waylandinputmethodconnection.cpp +++ b/connection/waylandinputmethodconnection.cpp @@ -30,7 +30,7 @@ namespace { // TODO: Deduplicate it. Those values are used in // minputcontextconnection, mimpluginmanager, -// mattributeextensionmanager and in input context implementations. +// and in input context implementations. const char * const FocusStateAttribute = "focusState"; const char * const ContentTypeAttribute = "contentType"; const char * const CorrectionAttribute = "correctionEnabled"; diff --git a/dbus_interfaces/minputmethodserver1interface.xml b/dbus_interfaces/minputmethodserver1interface.xml index 9dcde183..75c75596 100644 --- a/dbus_interfaces/minputmethodserver1interface.xml +++ b/dbus_interfaces/minputmethodserver1interface.xml @@ -48,13 +48,6 @@ - - - - - - - diff --git a/doc/src/mainpage.dox b/doc/src/mainpage.dox index 40aab606..1f6d512e 100644 --- a/doc/src/mainpage.dox +++ b/doc/src/mainpage.dox @@ -61,7 +61,6 @@ The following base classes are needed to implement an input method UI plugin: @subsection libmaliitclasses Useful classes -- @ref Maliit::AttributeExtension "AttributeExtension" : Register extensions such as key overrides. - @ref Maliit::InputMethod "InputMethod" : Listen to device orientation, language and raw key events. - @ref Maliit::PreeditInjectionEvent "PreeditInjectionEvent" : Extension for preedit text inside text edits. diff --git a/input-context/minputcontext.cpp b/input-context/minputcontext.cpp index 31467baa..7b189a43 100644 --- a/input-context/minputcontext.cpp +++ b/input-context/minputcontext.cpp @@ -615,9 +615,6 @@ void MInputContext::onDBusConnection() { qCDebug(lcMaliit) << Q_FUNC_INFO; - // using one attribute extension for everything - imServer->registerAttributeExtension(0, QString()); - // Force activation, since setFocusObject may have been called after // onDBusDisconnection set active to false or before the dbus connection. active = false; diff --git a/maliit-glib/maliitattributeextensionregistry.c b/maliit-glib/maliitattributeextensionregistry.c index 64ad07cc..9919a105 100644 --- a/maliit-glib/maliitattributeextensionregistry.c +++ b/maliit-glib/maliitattributeextensionregistry.c @@ -138,26 +138,6 @@ register_all_extensions (MaliitServer *server, gpointer user_data) for (iter = extensions; iter; iter = iter->next) { MaliitAttributeExtension *extension = MALIIT_ATTRIBUTE_EXTENSION (iter->data); - - if (maliit_server_call_register_attribute_extension_sync (server, - maliit_attribute_extension_get_id (extension), - maliit_attribute_extension_get_filename (extension), - NULL, - &error)) { - GHashTable *attributes = maliit_attribute_extension_get_attributes (extension); - GHashTableIter attributes_iter; - gpointer key; - gpointer value; - - g_hash_table_iter_init (&attributes_iter, attributes); - - while (g_hash_table_iter_next (&attributes_iter, &key, &value)) { - maliit_attribute_extension_registry_extension_changed(registry, extension, key, value); - } - } else { - g_warning ("Could not register an extension in mass registerer: %s", error->message); - g_clear_error (&error); - } } g_list_free (extensions); @@ -227,16 +207,7 @@ maliit_attribute_extension_registry_add_extension (MaliitAttributeExtensionRegis server = maliit_get_server_sync (NULL, &error); - if (server) { - if (!maliit_server_call_register_attribute_extension_sync (server, - id, - maliit_attribute_extension_get_filename (extension), - NULL, - &error)) { - g_warning ("Unable to register extension: %s", error->message); - g_clear_error (&error); - } - } else { + if (!server) { g_warning ("Unable to connect to server: %s", error->message); g_clear_error (&error); } @@ -264,15 +235,7 @@ maliit_attribute_extension_registry_remove_extension (MaliitAttributeExtensionRe server = maliit_get_server_sync (NULL, &error); - if (server) { - if (!maliit_server_call_unregister_attribute_extension_sync (server, - id, - NULL, - &error)) { - g_warning ("Unable to unregister extension: %s", error->message); - g_clear_error (&error); - } - } else { + if (!server) { g_warning ("Unable to connect to server: %s", error->message); g_clear_error (&error); } diff --git a/src/maliit/plugins/attributeextension.cpp b/src/maliit/plugins/attributeextension.cpp deleted file mode 100644 index 84503ae6..00000000 --- a/src/maliit/plugins/attributeextension.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/* * This file is part of Maliit framework * - * - * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). - * All rights reserved. - * - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License version 2.1 as published by the Free Software Foundation - * and appearing in the file LICENSE.LGPL included in the packaging - * of this file. - */ - - -#include -#include -#include - -#include - -MAttributeExtensionPrivate::MAttributeExtensionPrivate() - : id() -{ -} - -MAttributeExtension::MAttributeExtension(const MAttributeExtensionId &id, const QString &) - : d_ptr(new MAttributeExtensionPrivate()) -{ - Q_D(MAttributeExtension); - d->id = id; - d->keyOverrideData = QSharedPointer(new MKeyOverrideData()); -} - -MAttributeExtension::~MAttributeExtension() -{ - delete d_ptr; -} - - -MAttributeExtensionId MAttributeExtension::id() const -{ - Q_D(const MAttributeExtension); - return d->id; -} - -QSharedPointer MAttributeExtension::keyOverrideData() const -{ - Q_D(const MAttributeExtension); - return d->keyOverrideData; -} diff --git a/src/maliit/plugins/attributeextension.h b/src/maliit/plugins/attributeextension.h deleted file mode 100644 index ae4ac2c5..00000000 --- a/src/maliit/plugins/attributeextension.h +++ /dev/null @@ -1,61 +0,0 @@ -/* * This file is part of Maliit framework * - * - * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). - * All rights reserved. - * - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License version 2.1 as published by the Free Software Foundation - * and appearing in the file LICENSE.LGPL included in the packaging - * of this file. - */ - - - -#ifndef MATTRIBUTEEXTENSION_H -#define MATTRIBUTEEXTENSION_H - -#include -#include -#include - -class MAttributeExtensionId; -class MAttributeExtensionPrivate; -class MKeyOverrideData; - -/*! \ingroup pluginapi - * \brief Attribute extension. - */ -class MAttributeExtension : public QObject -{ - Q_OBJECT - Q_DISABLE_COPY(MAttributeExtension) - -public: - /*! - * \brief Constructor - */ - MAttributeExtension(const MAttributeExtensionId &id, const QString &fileName); - - /*! - * \brief Destructor - */ - ~MAttributeExtension(); - - MAttributeExtensionId id() const; - - //! Return the pointer to key override data. - QSharedPointer keyOverrideData() const; - -protected: - Q_DECLARE_PRIVATE(MAttributeExtension) - MAttributeExtensionPrivate *const d_ptr; - - friend class MAttributeExtensionManager; - friend class Ut_MAttributeExtension; - friend class Ut_MAttributeExtensionManager; -}; - -#endif - diff --git a/src/maliit/plugins/attributeextension_p.h b/src/maliit/plugins/attributeextension_p.h deleted file mode 100644 index 46aeac42..00000000 --- a/src/maliit/plugins/attributeextension_p.h +++ /dev/null @@ -1,36 +0,0 @@ -/* * This file is part of Maliit framework * - * - * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). - * All rights reserved. - * - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License version 2.1 as published by the Free Software Foundation - * and appearing in the file LICENSE.LGPL included in the packaging - * of this file. - */ - - -#ifndef MATTRIBUTEEXTENSION_P_H -#define MATTRIBUTEEXTENSION_P_H - -#include -#include "mattributeextensionid.h" -class MKeyOverrideData; - -class MAttributeExtensionPrivate -{ -public: - Q_DECLARE_PUBLIC(MAttributeExtension) - MAttributeExtensionPrivate(); - -private: - MAttributeExtensionId id; - QSharedPointer keyOverrideData; - - MAttributeExtension *q_ptr; -}; - -#endif - diff --git a/src/mattributeextensionid.cpp b/src/mattributeextensionid.cpp deleted file mode 100644 index 43a15391..00000000 --- a/src/mattributeextensionid.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/* * This file is part of Maliit framework * - * - * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). - * All rights reserved. - * - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License version 2.1 as published by the Free Software Foundation - * and appearing in the file LICENSE.LGPL included in the packaging - * of this file. - */ - - -#include "mattributeextensionid.h" - -#include - -namespace { - const int InvalidId = -1; - const int StandardId = -2; -} - -MAttributeExtensionId::MAttributeExtensionId() - : m_id(InvalidId) -{ -} - -MAttributeExtensionId::MAttributeExtensionId(int id, const QString &service) - : m_id(id), - m_service(service) -{ -} - -MAttributeExtensionId MAttributeExtensionId::standardAttributeExtensionId() -{ - return MAttributeExtensionId(StandardId, QString()); -} - -bool MAttributeExtensionId::isValid() const -{ - return m_id >= 0 && !m_service.isEmpty(); -} - -bool MAttributeExtensionId::operator==(const MAttributeExtensionId &other) const -{ - return (m_id == other.m_id) && (m_service == other.m_service); -} - -bool MAttributeExtensionId::operator!=(const MAttributeExtensionId &other) const -{ - return !operator==(other); -} - -QString MAttributeExtensionId::service() const -{ - return m_service; -} - -int MAttributeExtensionId::id() const -{ - return m_id; -} - -uint qHash(const MAttributeExtensionId &id) -{ - return qHash(QPair(id.m_id, id.m_service)); -} - diff --git a/src/mattributeextensionid.h b/src/mattributeextensionid.h deleted file mode 100644 index 5a4978d9..00000000 --- a/src/mattributeextensionid.h +++ /dev/null @@ -1,71 +0,0 @@ -/* * This file is part of Maliit framework * - * - * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). - * All rights reserved. - * - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License version 2.1 as published by the Free Software Foundation - * and appearing in the file LICENSE.LGPL included in the packaging - * of this file. - */ - - -#ifndef MATTRIBUTEEXTENSIONID_H -#define MATTRIBUTEEXTENSIONID_H - -#include -#include -#include - -//! \internal -/*! \ingroup maliitserver - * \brief Contains global unique identifier for an attribute extension. - * - * Such identifiers are generated by MAttributeExtensionManager::generateId. - */ -class MAttributeExtensionId -{ -public: - //! Construct invalid identifier. - MAttributeExtensionId(); - - //! Construct identifier with given application \a id and \a service name. - MAttributeExtensionId(int id, const QString &service); - - //! Return identifier for standard attribute extension - static MAttributeExtensionId standardAttributeExtensionId(); - - //! Return true if identifier is valid. - bool isValid() const; - - //! Returns true if \a other is equal to this object - bool operator==(const MAttributeExtensionId &other) const; - - //! Returns true if \a other is not equal to this object - bool operator!=(const MAttributeExtensionId &other) const; - - //! \return service part of the ID, given to constructor - QString service() const; - - //! Id given by application - int id() const; - -private: - //! Id given by application - int m_id; - - //! Unique application identifier - QString m_service; - - friend uint qHash(const MAttributeExtensionId &id); -}; - -//! Returns hash value for given \a id -uint qHash(const MAttributeExtensionId &id); - -//! \internal_end - -#endif - diff --git a/src/mattributeextensionmanager.cpp b/src/mattributeextensionmanager.cpp deleted file mode 100644 index 51f97ddd..00000000 --- a/src/mattributeextensionmanager.cpp +++ /dev/null @@ -1,262 +0,0 @@ -/* * This file is part of Maliit framework * - * - * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). - * All rights reserved. - * - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License version 2.1 as published by the Free Software Foundation - * and appearing in the file LICENSE.LGPL included in the packaging - * of this file. - */ - - -#include "mattributeextensionmanager.h" -#include "logging.h" -#include -#include - -#include -#include -#include -#include - -namespace { - const QString DefaultConfigurationPath = QString::fromLatin1(MALIIT_EXTENSIONS_DIR); - const char * const PreferredDomainSettingName(MALIIT_CONFIG_ROOT"preferred_domain"); - const char * const DomainItemName("_domain"); - const char * const KeysExtensionString("/keys"); - const char * const GlobalExtensionString("/"); - - const char * const FocusStateAttribute = "focusState"; -} - -MAttributeExtensionManager::MAttributeExtensionManager() - : copyPasteStatus(Maliit::InputMethodNoCopyPaste) -{ -} - -MAttributeExtensionManager::~MAttributeExtensionManager() -{ -} - -QList MAttributeExtensionManager::attributeExtensionIdList() const -{ - return attributeExtensions.keys(); -} - -QSharedPointer MAttributeExtensionManager::attributeExtension(const MAttributeExtensionId &id) const -{ - AttributeExtensionContainer::const_iterator iterator(attributeExtensions.find(id)); - - if (iterator != attributeExtensions.end()) - return iterator.value(); - return QSharedPointer(); -} - -bool MAttributeExtensionManager::contains(const MAttributeExtensionId &id) const -{ - return attributeExtensions.contains(id); -} - -void MAttributeExtensionManager::setCopyPasteState(bool copyAvailable, bool pasteAvailable) -{ - Maliit::CopyPasteState newStatus = Maliit::InputMethodNoCopyPaste; - - if (copyAvailable) { - newStatus = Maliit::InputMethodCopy; - } else if (pasteAvailable) { - newStatus = Maliit::InputMethodPaste; - } - - if (copyPasteStatus == newStatus) - return; - - copyPasteStatus = newStatus; - switch (newStatus) { - case Maliit::InputMethodNoCopyPaste: - break; - case Maliit::InputMethodCopy: - break; - case Maliit::InputMethodPaste: - break; - } -} - -void MAttributeExtensionManager::registerAttributeExtension(const MAttributeExtensionId &id, const QString &fileName) -{ - if (!id.isValid() || attributeExtensions.contains(id)) - return; - - // Only register default extension in the case of empty string. - // Don't register extension if user makes a typo in the file name. - if (!fileName.isEmpty()) { - QString absoluteFileName = fileName; - QFileInfo info(absoluteFileName); - if (info.isRelative()) - absoluteFileName = DefaultConfigurationPath + info.fileName(); - if (!QFile::exists(absoluteFileName)) - return; - } - - QSharedPointer attributeExtension(new MAttributeExtension(id, fileName)); - if (attributeExtension) { - attributeExtensions.insert(id, attributeExtension); - } -} - -void MAttributeExtensionManager::unregisterAttributeExtension(const MAttributeExtensionId &id) -{ - AttributeExtensionContainer::iterator iterator(attributeExtensions.find(id)); - - if (iterator == attributeExtensions.end()) { - return; - } - - attributeExtensions.remove(id); -} - -QMap > MAttributeExtensionManager::keyOverrides( - const MAttributeExtensionId &id) const -{ - QList > overrides; - QSharedPointer extension = attributeExtension(id); - if (extension) { - overrides = extension->keyOverrideData()->keyOverrides(); - } - QMap > overridesMap; - Q_FOREACH (const QSharedPointer &override, overrides) { - overridesMap.insert(override->keyId(), override); - } - return overridesMap; -} - -void MAttributeExtensionManager::setExtendedAttribute(const MAttributeExtensionId &id, - const QString &target, - const QString &targetItem, - const QString &attribute, - const QVariant &value) -{ - if (target == GlobalExtensionString) { - Q_EMIT globalAttributeChanged(id, targetItem, attribute, value); - return; - } - - if (!id.isValid() || attribute.isEmpty() || targetItem.isEmpty() || !value.isValid()) - return; - - QSharedPointer extension = attributeExtension(id); - - if (!extension) { - qCWarning(lcMaliitFw) << "Extended attribute change with invalid id"; - return; - } - - if (target == KeysExtensionString) { - // create key override if not exist. - bool newKeyOverrideCreated = extension->keyOverrideData()->createKeyOverride(targetItem); - QSharedPointer keyOverride = extension->keyOverrideData()->keyOverride(targetItem); - - Q_ASSERT(keyOverride); - const QByteArray byteArray = attribute.toLatin1(); - const char * const c_str = byteArray.data(); - - // Ignore l10n lengthvariants in QStrings for labels, always pick longest variant (first) - if (attribute == "label") { - QString label = value.toString(); - label = label.split(QChar(0x9c)).first(); - const QVariant newValue(label); - keyOverride->setProperty(c_str, newValue); - } else { - keyOverride->setProperty(c_str, value); - } - - // Q_EMIT signal to notify the new key override is created. - if (newKeyOverrideCreated) { - Q_EMIT keyOverrideCreated(); - } - } else { - qCWarning(lcMaliitFw) << "Invalid or incompatible attribute extension target:" << target; - } -} - - -void MAttributeExtensionManager::handleClientDisconnect(unsigned int clientId) -{ - // unregister toolbars registered by the lost connection - const QString service(QString::number(clientId)); - QSet::iterator i(attributeExtensionIds.begin()); - while (i != attributeExtensionIds.end()) { - if ((*i).service() == service) { - unregisterAttributeExtension(*i); - i = attributeExtensionIds.erase(i); - } else { - ++i; - } - } -} - -void MAttributeExtensionManager::handleExtendedAttributeUpdate(unsigned int clientId, int id, - const QString &target, const QString &targetName, - const QString &attribute, const QVariant &value) -{ - MAttributeExtensionId globalId(id, QString::number(clientId)); - if (globalId.isValid() && attributeExtensionIds.contains(globalId)) { - setExtendedAttribute(globalId, target, targetName, attribute, value); - } -} - -void MAttributeExtensionManager::handleAttributeExtensionRegistered(unsigned int clientId, - int id, const QString &attributeExtension) -{ - MAttributeExtensionId globalId(id, QString::number(clientId)); - if (globalId.isValid() && !attributeExtensionIds.contains(globalId)) { - registerAttributeExtension(globalId, attributeExtension); - attributeExtensionIds.insert(globalId); - } -} - -void MAttributeExtensionManager::handleAttributeExtensionUnregistered(unsigned int clientId, int id) -{ - MAttributeExtensionId globalId(id, QString::number(clientId)); - if (globalId.isValid() && attributeExtensionIds.contains(globalId)) { - unregisterAttributeExtension(globalId); - attributeExtensionIds.remove(globalId); - } -} - -void MAttributeExtensionManager::handleWidgetStateChanged(unsigned int clientId, - const QMap &newState, - const QMap &oldState, - bool focusChanged) - -{ - Q_UNUSED(oldState); - // toolbar change - MAttributeExtensionId oldAttributeExtensionId; - MAttributeExtensionId newAttributeExtensionId; - oldAttributeExtensionId = attributeExtensionId; - - if (!newAttributeExtensionId.isValid()) { - newAttributeExtensionId = MAttributeExtensionId::standardAttributeExtensionId(); - } - - QVariant variant = newState[FocusStateAttribute]; - if (not variant.isValid()) { - qCCritical(lcMaliitFw) << Q_FUNC_INFO << "Invalid focus state"; - } - bool widgetFocusState = variant.toBool(); - - // compare the toolbar id (global) - if (oldAttributeExtensionId != newAttributeExtensionId) { - Q_EMIT attributeExtensionIdChanged(newAttributeExtensionId); - // store the new used toolbar id(global). - attributeExtensionId = newAttributeExtensionId; - } - // this happens when we focus on a text widget with no attribute extensions. - else if (focusChanged && widgetFocusState) - { - Q_EMIT attributeExtensionIdChanged(newAttributeExtensionId); - } -} diff --git a/src/mattributeextensionmanager.h b/src/mattributeextensionmanager.h deleted file mode 100644 index 7f35b36e..00000000 --- a/src/mattributeextensionmanager.h +++ /dev/null @@ -1,163 +0,0 @@ -/* * This file is part of Maliit framework * - * - * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). - * All rights reserved. - * - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License version 2.1 as published by the Free Software Foundation - * and appearing in the file LICENSE.LGPL included in the packaging - * of this file. - */ - - -#ifndef MATTRIBUTEEXTENSIONMANAGER_H -#define MATTRIBUTEEXTENSIONMANAGER_H - -#include -#include -#include -#include -#include - -#include - -#include -#include -#include "mattributeextensionid.h" -#include "mimsettings.h" - -//! \internal -/*! \ingroup maliitserver - \brief The MAttributeExtensionManager class manager the virtual keyboard attribute extensions. - - AttributeExtensionManager loads and manages key overrides. -*/ -class MAttributeExtensionManager : public QObject -{ - Q_OBJECT - Q_DISABLE_COPY(MAttributeExtensionManager) - -public: - /*! - * \brief Default constructor. - */ - MAttributeExtensionManager(); - - /*! - *\brief Destructor. - */ - virtual ~MAttributeExtensionManager(); - - /*! - * \brief Register an input method attribute extension which is defined in \a fileName with the unique identifier \a id. - * AttributeExtensionManager can load a attribute extension's content according \a id and \a fileName, and cache it for the - * future use. The \a id should be unique, and the \a fileName is the absolute file name of the attribute extension. - */ - void registerAttributeExtension(const MAttributeExtensionId &id, const QString &fileName); - - /*! - * \brief Unregister an input method attribute extension which unique identifier is \a id. - * AttributeExtensionManager will remove the cached widget according \a id. - */ - void unregisterAttributeExtension(const MAttributeExtensionId &id); - - /*! - *\brief Returns widget data definition for gived \a id. - */ - QSharedPointer attributeExtension(const MAttributeExtensionId &id) const; - - /*! - *\brief Returns key overrides definition for gived \a id. - */ - QMap > keyOverrides(const MAttributeExtensionId &id) const; - - /*! - *\brief Returns whether registered attribute extensions contain \a id. - */ - bool contains(const MAttributeExtensionId &id) const; - - /*! - *\brief Sets the \a attribute of the \a targetItem in the attribute extension \a target which has unique\a id to \a value. - */ - void setExtendedAttribute(const MAttributeExtensionId &id, - const QString &target, - const QString &targetItem, - const QString &attribute, - const QVariant &value); -public Q_SLOTS: - /*! - * \brief Set copy/paste button state: hide it, show copy or show paste - * \param copyAvailable True if text is selected - * \param pasteAvailable True if clipboard content is not empty - */ - void setCopyPasteState(bool copyAvailable, bool pasteAvailable); - - void handleClientDisconnect(unsigned int clientId); - void handleAttributeExtensionRegistered(unsigned int clientId, int id, const QString &attributeExtension); - void handleAttributeExtensionUnregistered(unsigned int clientId, int id); - void handleExtendedAttributeUpdate(unsigned int clientId, int id, - const QString &target, const QString &targetName, - const QString &attribute, const QVariant &value); - void handleWidgetStateChanged(unsigned int clientId, const QMap &newState, - const QMap &oldState, bool focusChanged); - -Q_SIGNALS: - //! This signal is emited when a new key override is created. - void keyOverrideCreated(); - - //! Emitted when attribute extension has changed - void attributeExtensionIdChanged(const MAttributeExtensionId &id); - - /*! - * \brief This signal is emitted when application wants to change global attribute - * that affects the whole input methods framework. - * \param id the attribute extension id - * \param targetItem Item name - * \param attribute Attribute name - * \param value New attribute value - */ - void globalAttributeChanged(const MAttributeExtensionId &id, - const QString &targetItem, - const QString &attribute, - const QVariant &value); - - /* - * \brief Emitted when attribute is changed by framework or plugin. - * \param id the unique identifier of a registered extended attribute. - * \param target a string specifying the target for the attribute. - * \param targetItem the item name. - * \param attribute attribute to be changed. - * \param value new value. - * \sa handleExtendedAttributeUpdate() - */ - void notifyExtensionAttributeChanged(int id, - const QString &target, - const QString &targetItem, - const QString &attribute, - const QVariant &value); - -private: - /*! - * \brief Returns a list of the id for all attribute extensions' ids. - */ - QList attributeExtensionIdList() const; - - typedef QHash > AttributeExtensionContainer; - //! all registered attribute extensions - AttributeExtensionContainer attributeExtensions; - - MAttributeExtensionId attributeExtensionId; //current attribute extension id - QSet attributeExtensionIds; //all attribute extension ids - - //! Copy/paste button status - Maliit::CopyPasteState copyPasteStatus; - - friend class Ut_MAttributeExtensionManager; -}; - -//! \internal_end - -#endif - diff --git a/src/mimpluginmanager.cpp b/src/mimpluginmanager.cpp index 5cdb735f..2f4fef5d 100644 --- a/src/mimpluginmanager.cpp +++ b/src/mimpluginmanager.cpp @@ -16,8 +16,6 @@ #include "mimpluginmanager.h" #include "mimpluginmanager_p.h" #include -#include "mattributeextensionmanager.h" -#include "msharedattributeextensionmanager.h" #include #include "mimsettings.h" #include "mimhwkeyboardtracker.h" @@ -65,8 +63,6 @@ MIMPluginManagerPrivate::MIMPluginManagerPrivate(const QSharedPointer connect(d->mICConnection.data(), SIGNAL(widgetStateChanged(uint,QMap,QMap,bool)), this, SLOT(handleWidgetStateChanged(uint,QMap,QMap,bool))); - // Connect connection and MAttributeExtensionManager - connect(d->mICConnection.data(), SIGNAL(copyPasteStateChanged(bool,bool)), - d->attributeExtensionManager.data(), SLOT(setCopyPasteState(bool, bool))); - - connect(d->mICConnection.data(), SIGNAL(widgetStateChanged(uint,QMap,QMap,bool)), - d->attributeExtensionManager.data(), SLOT(handleWidgetStateChanged(uint,QMap,QMap,bool))); - - connect(d->mICConnection.data(), SIGNAL(attributeExtensionRegistered(uint, int, QString)), - d->attributeExtensionManager.data(), SLOT(handleAttributeExtensionRegistered(uint, int, QString))); - - connect(d->mICConnection.data(), SIGNAL(attributeExtensionUnregistered(uint, int)), - d->attributeExtensionManager.data(), SLOT(handleAttributeExtensionUnregistered(uint, int))); - - connect(d->mICConnection.data(), SIGNAL(extendedAttributeChanged(uint, int, QString, QString, QString, QVariant)), - d->attributeExtensionManager.data(), SLOT(handleExtendedAttributeUpdate(uint, int, QString, QString, QString, QVariant))); - - connect(d->attributeExtensionManager.data(), SIGNAL(notifyExtensionAttributeChanged(int, QString, QString, QString, QVariant)), - d->mICConnection.data(), SLOT(notifyExtendedAttributeChanged(int, QString, QString, QString, QVariant))); - - connect(d->mICConnection.data(), SIGNAL(clientDisconnected(uint)), - d->attributeExtensionManager.data(), SLOT(handleClientDisconnect(uint))); - - connect(d->mICConnection.data(), SIGNAL(attributeExtensionRegistered(uint, int, QString)), - d->sharedAttributeExtensionManager.data(), SLOT(handleAttributeExtensionRegistered(uint, int, QString))); - - connect(d->mICConnection.data(), SIGNAL(attributeExtensionUnregistered(uint, int)), - d->sharedAttributeExtensionManager.data(), SLOT(handleAttributeExtensionUnregistered(uint, int))); - - connect(d->mICConnection.data(), SIGNAL(extendedAttributeChanged(uint, int, QString, QString, QString, QVariant)), - d->sharedAttributeExtensionManager.data(), SLOT(handleExtendedAttributeUpdate(uint, int, QString, QString, QString, QVariant))); - - connect(d->sharedAttributeExtensionManager.data(), SIGNAL(notifyExtensionAttributeChanged(QList, int, QString, QString, QString, QVariant)), - d->mICConnection.data(), SLOT(notifyExtendedAttributeChanged(QList, int, QString, QString, QString, QVariant))); - - connect(d->mICConnection.data(), SIGNAL(clientDisconnected(uint)), - d->sharedAttributeExtensionManager.data(), SLOT(handleClientDisconnect(uint))); connect(d->mICConnection.data(), SIGNAL(focusChanged(WId)), this, SLOT(handleAppFocusChanged(WId))); - connect(d->attributeExtensionManager.data(), SIGNAL(globalAttributeChanged(MAttributeExtensionId,QString,QString,QVariant)), - this, SLOT(onGlobalAttributeChanged(MAttributeExtensionId,QString,QString,QVariant))); d->paths = MImSettings(MImPluginPaths).value(QStringList(DefaultPluginLocation)).toStringList(); d->blacklist = MImSettings(MImPluginDisabled).value().toStringList(); @@ -1408,29 +1366,4 @@ QSet MIMPluginManager::targets() return d->targets; } -void MIMPluginManager::onGlobalAttributeChanged(const MAttributeExtensionId &id, - const QString &targetItem, - const QString &attribute, - const QVariant &value) -{ - Q_D(MIMPluginManager); - - if (targetItem == InputMethodItem - && attribute == LoadAll) { - - if (value.toBool()) { - if (const QSharedPointer &extension = - d->attributeExtensionManager->attributeExtension(id)) { - // Create an object that is bound to the life time of the - // attribute extension (through QObject ownership hierarchy). - // Upon destruction, it will reset the all-subviews-enabled - // override. - (void) new MImSubViewOverride(&d->onScreenPlugins, extension.data()); - } - } - - setAllSubViewsEnabled(value.toBool()); - } -} - #include "moc_mimpluginmanager.cpp" diff --git a/src/mimpluginmanager.h b/src/mimpluginmanager.h index ea89737b..ccecc7be 100644 --- a/src/mimpluginmanager.h +++ b/src/mimpluginmanager.h @@ -23,16 +23,13 @@ #include #include -#include "mattributeextensionid.h" #include "minputcontextconnection.h" QT_BEGIN_NAMESPACE class QRegion; QT_END_NAMESPACE class MIMPluginManagerPrivate; -class MAttributeExtensionId; class MAbstractInputMethod; -class MAttributeExtensionManager; namespace Maliit { @@ -137,17 +134,6 @@ private Q_SLOTS: Qt::KeyboardModifiers modifiers, const QString &text, bool autoRepeat, int count, quint32 nativeScanCode, quint32 nativeModifiers, unsigned long time); - /*! - * \brief Handle global attribute change - * \param id id of the attribute extension that triggered this change - * \param targetItem Item name - * \param attribute Attribute name - * \param value New attribute value - */ - void onGlobalAttributeChanged(const MAttributeExtensionId &id, - const QString &targetItem, - const QString &attribute, - const QVariant &value); private: QSet targets(); diff --git a/src/mimpluginmanager_p.h b/src/mimpluginmanager_p.h index c6627b20..7cb2536e 100644 --- a/src/mimpluginmanager_p.h +++ b/src/mimpluginmanager_p.h @@ -16,7 +16,6 @@ #include -#include "mattributeextensionid.h" #include "minputmethodhost.h" #include "mimonscreenplugins.h" #include "mimsettings.h" @@ -34,8 +33,6 @@ namespace Plugins { class MInputContextConnection; class MIMPluginManager; -class MAttributeExtensionManager; -class MSharedAttributeExtensionManager; class MImSettings; class MAbstractInputMethod; class MIMPluginManagerAdaptor; @@ -172,9 +169,6 @@ class MIMPluginManagerPrivate int lastOrientation; - QScopedPointer attributeExtensionManager; - QScopedPointer sharedAttributeExtensionManager; - QSharedPointer m_platform; }; diff --git a/src/msharedattributeextensionmanager.cpp b/src/msharedattributeextensionmanager.cpp deleted file mode 100644 index edfdd53c..00000000 --- a/src/msharedattributeextensionmanager.cpp +++ /dev/null @@ -1,97 +0,0 @@ -/* * This file is part of Maliit framework * - * - * Copyright (C) 2012 Mattia Barbon - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License version 2.1 as published by the Free Software Foundation - * and appearing in the file LICENSE.LGPL included in the packaging - * of this file. - */ - -#include "msharedattributeextensionmanager.h" -#include "mimsettings.h" - -#include - -struct MSharedAttributeExtensionManagerPluginSetting -{ - MSharedAttributeExtensionManagerPluginSetting(const QString &key, QVariantMap attributes) : - setting(key), - attributes(attributes) - { - } - - MImSettings setting; - QVariantMap attributes; -}; - - -MSharedAttributeExtensionManager::MSharedAttributeExtensionManager() -{ -} - -MSharedAttributeExtensionManager::~MSharedAttributeExtensionManager() -{ -} - -void MSharedAttributeExtensionManager::handleClientDisconnect(unsigned int clientId) -{ - clientIds.removeOne(clientId); -} - -void MSharedAttributeExtensionManager::handleAttributeExtensionRegistered(unsigned int clientId, int id, - const QString &attributeExtension) -{ - Q_UNUSED(attributeExtension); - - if (id != PluginSettings) - return; - if (clientIds.contains(clientId)) - return; - - clientIds.append(clientId); -} - -void MSharedAttributeExtensionManager::handleAttributeExtensionUnregistered(unsigned int clientId, int id) -{ - if (id != PluginSettings) - return; - - clientIds.removeOne(clientId); -} - -void MSharedAttributeExtensionManager::handleExtendedAttributeUpdate(unsigned int clientId, int id, - const QString &target, const QString &targetName, - const QString &attribute, const QVariant &value) -{ - Q_UNUSED(clientId); - - if (id != PluginSettings) - return; - - QString key = QString::fromLatin1("%1/%2/%3").arg(target, targetName, attribute); - SharedAttributeExtensionContainer::iterator it = sharedAttributeExtensions.find(key); - - if (it == sharedAttributeExtensions.end()) - return; - - it->data()->setting.set(value); -} - -void MSharedAttributeExtensionManager::attributeValueChanged() -{ - MImSettings *value = qobject_cast(sender()); - - if (!value) - return; - if (sharedAttributeExtensions.find(value->key()) == sharedAttributeExtensions.end()) - return; - - const QString fullName = value->key(); - const QString &target = QString::fromLatin1("/") + fullName.section('/', 1, 1); - const QString &targetItem = fullName.section('/', 2, -2); - const QString &attribute = fullName.section('/', -1, -1); - - Q_EMIT notifyExtensionAttributeChanged(clientIds, PluginSettings, target, targetItem, attribute, value->value()); -} diff --git a/src/msharedattributeextensionmanager.h b/src/msharedattributeextensionmanager.h deleted file mode 100644 index 2f95cdb4..00000000 --- a/src/msharedattributeextensionmanager.h +++ /dev/null @@ -1,76 +0,0 @@ -/* * This file is part of Maliit framework * - * - * Copyright (C) 2012 Mattia Barbon - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License version 2.1 as published by the Free Software Foundation - * and appearing in the file LICENSE.LGPL included in the packaging - * of this file. - */ - - -#ifndef MSHAREDATTRIBUTEEXTENSIONMANAGER_H -#define MSHAREDATTRIBUTEEXTENSIONMANAGER_H - -#include -#include -#include - -class MSharedAttributeExtensionManagerPluginSetting; - -//! \internal -/*! \ingroup maliitserver - * \brief Manages attribute extensions shared between clients. - * - * Currently handles only plugin settings, backed by MImSettings. - */ -class MSharedAttributeExtensionManager : public QObject -{ - Q_OBJECT - -public: - enum ReservedExtensionIds - { - PluginSettings = -3, - PluginSettingsList = -4 - }; - - MSharedAttributeExtensionManager(); - virtual ~MSharedAttributeExtensionManager(); - -public Q_SLOTS: - void handleClientDisconnect(unsigned int clientId); - void handleAttributeExtensionRegistered(unsigned int clientId, int id, const QString &attributeExtension); - void handleAttributeExtensionUnregistered(unsigned int clientId, int id); - void handleExtendedAttributeUpdate(unsigned int clientId, int id, - const QString &target, const QString &targetName, - const QString &attribute, const QVariant &value); - -Q_SIGNALS: - /*! - * \brief Emitted when setting value is changed - * \param clientIds list of clients subscribed to the value - * \param id the unique identifier of a registered extended attribute. - * \param target a string specifying the target for the attribute. - * \param targetItem the item name. - * \param attribute attribute to be changed. - * \param value new value. - */ - void notifyExtensionAttributeChanged(const QList &clientIds, - int id, - const QString &target, - const QString &targetItem, - const QString &attribute, - const QVariant &value); - -private: - Q_SLOT void attributeValueChanged(); - - typedef QHash > SharedAttributeExtensionContainer; - //! all registered attribute extensions - SharedAttributeExtensionContainer sharedAttributeExtensions; - QList clientIds; -}; - -#endif // MSHAREDATTRIBUTEEXTENSIONMANAGER_H diff --git a/tests/ft_mimpluginmanager/ft_mimpluginmanager.cpp b/tests/ft_mimpluginmanager/ft_mimpluginmanager.cpp index 4eaba2f9..4ff93c46 100644 --- a/tests/ft_mimpluginmanager/ft_mimpluginmanager.cpp +++ b/tests/ft_mimpluginmanager/ft_mimpluginmanager.cpp @@ -11,7 +11,6 @@ #include #include #include -#include #include #include diff --git a/tests/ut_mattributeextensionmanager/.gitignore b/tests/ut_mattributeextensionmanager/.gitignore deleted file mode 100644 index 6eb0c6b1..00000000 --- a/tests/ut_mattributeextensionmanager/.gitignore +++ /dev/null @@ -1 +0,0 @@ -ut_mattributeextensionmanager diff --git a/tests/ut_mattributeextensionmanager/ut_mattributeextensionmanager.cpp b/tests/ut_mattributeextensionmanager/ut_mattributeextensionmanager.cpp deleted file mode 100644 index 19e959e5..00000000 --- a/tests/ut_mattributeextensionmanager/ut_mattributeextensionmanager.cpp +++ /dev/null @@ -1,99 +0,0 @@ -/* * This file is part of meego-keyboard * - * - * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). - * All rights reserved. - * - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License version 2.1 as published by the Free Software Foundation - * and appearing in the file LICENSE.LGPL included in the packaging - * of this file. - */ - - -#include "ut_mattributeextensionmanager.h" - -#include "core-utils.h" - -#include -#include -#include -#include -#include -#include - -namespace { - const QString testDirectory = "/ut_mattributeextensionmanager"; -} - -void Ut_MAttributeExtensionManager::initTestCase() -{ -} - -void Ut_MAttributeExtensionManager::cleanupTestCase() -{ -} - -void Ut_MAttributeExtensionManager::init() -{ - subject = new MAttributeExtensionManager; -} - -void Ut_MAttributeExtensionManager::cleanup() -{ - delete subject; - subject = 0; -} - -void Ut_MAttributeExtensionManager::testSetExtendedAttribute() -{ - MAttributeExtensionId id1(1, "Ut_MAttributeExtensionManager"); - MAttributeExtensionId id2(2, "Ut_MAttributeExtensionManager"); - - QList idList; - idList << id1 << id2; - - int attributteExtentionCount = 0; - // register all extended attributes - for (int i = 0; i < idList.count(); i++) { - subject->registerAttributeExtension(idList.at(i), ""); - attributteExtentionCount ++; - QTest::qWait(50); - QCOMPARE(subject->attributeExtensionIdList().count(), attributteExtentionCount); - } - - QSignalSpy spy(subject, SIGNAL(keyOverrideCreated())); - QVERIFY(spy.isValid()); - for (int i = 0; i < idList.count(); i++) { - QCOMPARE(subject->keyOverrides(idList.at(i)).count(), 0); - - // set extended attribute not registered before. - subject->setExtendedAttribute(idList.at(i), - "/keys", - "testKey", - "label", - QVariant("testLabel")); - - // new key overrides will be created - QCOMPARE(spy.count(), 1); - spy.clear(); - QCOMPARE(subject->keyOverrides(idList.at(i)).count(), 1); - QVERIFY(subject->keyOverrides(idList.at(i)).value("testKey")); - QCOMPARE(subject->keyOverrides(idList.at(i)).value("testKey")->label(), QString("testLabel")); - } - - spy.clear(); - // item attribute is modified in one, the same item attribute must not change in the other one. - subject->setExtendedAttribute(idList.at(0), - "/keys", - "testKey", - "icon", - QVariant("testIcon")); - QCOMPARE(subject->keyOverrides(idList.at(0)).count(), 1); - QVERIFY(subject->keyOverrides(idList.at(0)).value("testKey")); - QCOMPARE(subject->keyOverrides(idList.at(0)).value("testKey")->icon(), QString("testIcon")); - QVERIFY(subject->keyOverrides(idList.at(1)).value("testKey")->icon().isEmpty()); -} - -QTEST_MAIN(Ut_MAttributeExtensionManager); diff --git a/tests/ut_mattributeextensionmanager/ut_mattributeextensionmanager.h b/tests/ut_mattributeextensionmanager/ut_mattributeextensionmanager.h deleted file mode 100644 index eb66385d..00000000 --- a/tests/ut_mattributeextensionmanager/ut_mattributeextensionmanager.h +++ /dev/null @@ -1,37 +0,0 @@ -/* * This file is part of meego-keyboard * - * - * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). - * All rights reserved. - * - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License version 2.1 as published by the Free Software Foundation - * and appearing in the file LICENSE.LGPL included in the packaging - * of this file. - */ - -#ifndef UT_MATTRIBUTEEXTENSIONMANAGER_H -#define UT_MATTRIBUTEEXTENSIONMANAGER_H - -#include -#include - -class MAttributeExtensionManager; - -class Ut_MAttributeExtensionManager : public QObject -{ - Q_OBJECT - -private Q_SLOTS: - void initTestCase(); - void cleanupTestCase(); - void init(); - void cleanup(); - void testSetExtendedAttribute(); - -private: - MAttributeExtensionManager *subject; -}; - -#endif diff --git a/tests/ut_mimpluginmanager/ut_mimpluginmanager.cpp b/tests/ut_mimpluginmanager/ut_mimpluginmanager.cpp index f28ba502..d0f7ef30 100644 --- a/tests/ut_mimpluginmanager/ut_mimpluginmanager.cpp +++ b/tests/ut_mimpluginmanager/ut_mimpluginmanager.cpp @@ -22,9 +22,6 @@ #include #include -#include "mattributeextensionmanager.h" -#include "msharedattributeextensionmanager.h" - typedef QSet HandlerStates; Q_DECLARE_METATYPE(HandlerStates); Q_DECLARE_METATYPE(Maliit::HandlerState); diff --git a/tests/ut_mimpluginmanagerconfig/ut_mimpluginmanagerconfig.cpp b/tests/ut_mimpluginmanagerconfig/ut_mimpluginmanagerconfig.cpp index 910eae93..3295b4c0 100644 --- a/tests/ut_mimpluginmanagerconfig/ut_mimpluginmanagerconfig.cpp +++ b/tests/ut_mimpluginmanagerconfig/ut_mimpluginmanagerconfig.cpp @@ -30,9 +30,6 @@ #include #include -#include "mattributeextensionmanager.h" -#include "msharedattributeextensionmanager.h" - using namespace std::tr1; typedef QSet HandlerStates; From 1454967a3965738d7a2bd314f1eac66f6ce70579 Mon Sep 17 00:00:00 2001 From: Rodney Dawes Date: Wed, 8 Jun 2022 17:50:59 -0400 Subject: [PATCH 07/13] Remove extended attribute API --- connection/dbusinputcontextconnection.cpp | 34 ------------------- connection/dbusinputcontextconnection.h | 12 ------- connection/dbusserverconnection.cpp | 15 -------- connection/dbusserverconnection.h | 8 ----- connection/mimserverconnection.cpp | 10 ------ connection/mimserverconnection.h | 12 ------- connection/minputcontextconnection.cpp | 26 -------------- connection/minputcontextconnection.h | 31 ----------------- .../minputmethodcontext1interface.xml | 7 ---- .../minputmethodserver1interface.xml | 7 ---- input-context/minputcontext.cpp | 31 ----------------- input-context/minputcontext.h | 2 -- .../maliitattributeextensionregistry.c | 14 +------- .../ut_mimpluginmanager.cpp | 18 +--------- 14 files changed, 2 insertions(+), 225 deletions(-) diff --git a/connection/dbusinputcontextconnection.cpp b/connection/dbusinputcontextconnection.cpp index 09fb9637..2a90297f 100644 --- a/connection/dbusinputcontextconnection.cpp +++ b/connection/dbusinputcontextconnection.cpp @@ -245,35 +245,6 @@ DBusInputContextConnection::updateInputMethodArea(const QRegion ®ion) } } -void -DBusInputContextConnection::notifyExtendedAttributeChanged(int id, - const QString &target, - const QString &targetItem, - const QString &attribute, - const QVariant &value) -{ - ComMeegoInputmethodInputcontext1Interface *proxy = mProxys.value(activeConnection); - if (proxy) { - proxy->notifyExtendedAttributeChanged(id, target, targetItem, attribute, QDBusVariant(value)); - } -} - -void -DBusInputContextConnection::notifyExtendedAttributeChanged(const QList &clientIds, - int id, - const QString &target, - const QString &targetItem, - const QString &attribute, - const QVariant &value) -{ - Q_FOREACH (int clientId, clientIds) { - ComMeegoInputmethodInputcontext1Interface *proxy = mProxys.value(clientId); - if (proxy) { - proxy->notifyExtendedAttributeChanged(id, target, targetItem, attribute, QDBusVariant(value)); - } - } -} - unsigned int DBusInputContextConnection::connectionNumber() { @@ -334,8 +305,3 @@ void DBusInputContextConnection::processKeyEvent(int keyType, int keyCode, int m { MInputContextConnection::processKeyEvent(connectionNumber(), static_cast(keyType), static_cast(keyCode), static_cast(modifiers), text, autoRepeat, count, nativeScanCode, nativeModifiers, time); } - -void DBusInputContextConnection::setExtendedAttribute(int id, const QString &target, const QString &targetItem, const QString &attribute, const QDBusVariant &value) -{ - MInputContextConnection::setExtendedAttribute(connectionNumber(), id, target, targetItem, attribute, value.variant()); -} diff --git a/connection/dbusinputcontextconnection.h b/connection/dbusinputcontextconnection.h index 992736f0..c10894b5 100644 --- a/connection/dbusinputcontextconnection.h +++ b/connection/dbusinputcontextconnection.h @@ -53,17 +53,6 @@ class DBusInputContextConnection : public MInputContextConnection, virtual QString selection(bool &valid); virtual void sendActivationLostEvent(); virtual void updateInputMethodArea(const QRegion ®ion); - virtual void notifyExtendedAttributeChanged(int id, - const QString &target, - const QString &targetItem, - const QString &attribute, - const QVariant &value); - virtual void notifyExtendedAttributeChanged(const QList &clientIds, - int id, - const QString &target, - const QString &targetItem, - const QString &attribute, - const QVariant &value); //! \reimp_end void activateContext(); @@ -77,7 +66,6 @@ class DBusInputContextConnection : public MInputContextConnection, void appOrientationChanged(int angle); void setCopyPasteState(bool copyAvailable, bool pasteAvailable); void processKeyEvent(int keyType, int keyCode, int modifiers, const QString &text, bool autoRepeat, int count, uint nativeScanCode, uint nativeModifiers, uint time); - void setExtendedAttribute(int id, const QString &target, const QString &targetItem, const QString &attribute, const QDBusVariant &value); private Q_SLOTS: void newConnection(const QDBusConnection &connection); diff --git a/connection/dbusserverconnection.cpp b/connection/dbusserverconnection.cpp index 87fa4bc4..cfc26c41 100644 --- a/connection/dbusserverconnection.cpp +++ b/connection/dbusserverconnection.cpp @@ -219,27 +219,12 @@ void DBusServerConnection::processKeyEvent(QEvent::Type keyType, Qt::Key keyCode mProxy->processKeyEvent(keyType, keyCode, modifiers, text, autoRepeat, count, nativeScanCode, nativeModifiers, time); } -void DBusServerConnection::setExtendedAttribute(int id, const QString &target, const QString &targetItem, - const QString &attribute, const QVariant &value) -{ - if (!mProxy) - return; - - mProxy->setExtendedAttribute(id, target, targetItem, attribute, QDBusVariant(value)); -} - void DBusServerConnection::keyEvent(int type, int key, int modifiers, const QString &text, bool autoRepeat, int count, uchar requestType) { keyEvent(type, key, modifiers, text, autoRepeat, count, static_cast(requestType)); } -void DBusServerConnection::notifyExtendedAttributeChanged(int id, const QString &target, const QString &targetItem, - const QString &attribute, const QDBusVariant &value) -{ - extendedAttributeChanged(id, target, targetItem, attribute, value.variant()); -} - bool DBusServerConnection::preeditRectangle(int &x, int &y, int &width, int &height) const { bool valid; diff --git a/connection/dbusserverconnection.h b/connection/dbusserverconnection.h index 014c0aec..41589e6f 100644 --- a/connection/dbusserverconnection.h +++ b/connection/dbusserverconnection.h @@ -48,8 +48,6 @@ class DBusServerConnection : public MImServerConnection Qt::KeyboardModifiers modifiers, const QString &text, bool autoRepeat, int count, quint32 nativeScanCode, quint32 nativeModifiers, unsigned long time); - virtual void setExtendedAttribute(int id, const QString &target, const QString &targetItem, - const QString &attribute, const QVariant &value); //! reimpl end //! forwarding methods for InputContextAdaptor @@ -57,12 +55,6 @@ class DBusServerConnection : public MImServerConnection void keyEvent(int type, int key, int modifiers, const QString &text, bool autoRepeat, int count, uchar requestType); - void notifyExtendedAttributeChanged(int id, - const QString &target, - const QString &targetItem, - const QString &attribute, - const QDBusVariant &value); - bool preeditRectangle(int &x, int &y, int &width, int &height) const; bool selection(QString &selection) const; diff --git a/connection/mimserverconnection.cpp b/connection/mimserverconnection.cpp index 72176f23..6c7906cf 100644 --- a/connection/mimserverconnection.cpp +++ b/connection/mimserverconnection.cpp @@ -90,13 +90,3 @@ void MImServerConnection::processKeyEvent(QEvent::Type keyType, Qt::Key keyCode, Q_UNUSED(nativeModifiers); Q_UNUSED(time); } - -void MImServerConnection::setExtendedAttribute(int id, const QString &target, const QString &targetItem, - const QString &attribute, const QVariant &value) -{ - Q_UNUSED(id); - Q_UNUSED(target); - Q_UNUSED(targetItem); - Q_UNUSED(attribute); - Q_UNUSED(value); -} diff --git a/connection/mimserverconnection.h b/connection/mimserverconnection.h index fd38a9d7..7df9da00 100644 --- a/connection/mimserverconnection.h +++ b/connection/mimserverconnection.h @@ -45,8 +45,6 @@ class MImServerConnection : public QObject Qt::KeyboardModifiers modifiers, const QString &text, bool autoRepeat, int count, quint32 nativeScanCode, quint32 nativeModifiers, unsigned long time); - virtual void setExtendedAttribute(int id, const QString &target, const QString &targetItem, - const QString &attribute, const QVariant &value); public: /*! \brief Notifies about connection to server being established. @@ -162,16 +160,6 @@ class MImServerConnection : public QObject */ Q_SIGNAL void getSelection(QString &selection, bool &valid) const; - /*! - *\brief Informs application that input method server has changed the \a attribute of the \a targetItem - * in the attribute extension \a target which has unique \a id to \a value. - */ - Q_SIGNAL void extendedAttributeChanged(int id, - const QString &target, - const QString &targetItem, - const QString &attribute, - const QVariant &value); - private: Q_DISABLE_COPY(MImServerConnection) diff --git a/connection/minputcontextconnection.cpp b/connection/minputcontextconnection.cpp index e06b4a65..8b5dd992 100644 --- a/connection/minputcontextconnection.cpp +++ b/connection/minputcontextconnection.cpp @@ -329,12 +329,6 @@ void MInputContextConnection::processKeyEvent( nativeScanCode, nativeModifiers, time); } -void MInputContextConnection::setExtendedAttribute( - unsigned int connectionId, int id, const QString &target, const QString &targetName, - const QString &attribute, const QVariant &value) -{ - Q_EMIT extendedAttributeChanged(connectionId, id, target, targetName, attribute, value); -} /* End handlers for inbound communication */ bool MInputContextConnection::detectableAutoRepeat() @@ -504,26 +498,6 @@ void MInputContextConnection::updateInputMethodArea(const QRegion ®ion) Q_UNUSED(region); } -void MInputContextConnection::notifyExtendedAttributeChanged(int , - const QString &, - const QString &, - const QString &, - const QVariant &) -{ - // empty default implementation -} - -void MInputContextConnection::notifyExtendedAttributeChanged(const QList &, - int , - const QString &, - const QString &, - const QString &, - const QVariant &) -{ - // empty default implementation -} - - QVariantMap MInputContextConnection::widgetState() const { return mWidgetState; diff --git a/connection/minputcontextconnection.h b/connection/minputcontextconnection.h index f2acf93e..199311bc 100644 --- a/connection/minputcontextconnection.h +++ b/connection/minputcontextconnection.h @@ -260,37 +260,10 @@ class MInputContextConnection: public QObject Qt::KeyboardModifiers modifiers, const QString &text, bool autoRepeat, int count, quint32 nativeScanCode, quint32 nativeModifiers, unsigned long time); - /*! - * \brief Sets the \a attribute for the \a target in the extended attribute which has unique \a id to \a value. - */ - void setExtendedAttribute(unsigned int clientId, int id, const QString &target, - const QString &targetItem, const QString &attribute, const QVariant &value); - public Q_SLOTS: //! Update \a region covered by virtual keyboard virtual void updateInputMethodArea(const QRegion ®ion); - /*! - * \brief Informs current application that input method servers has changed the \a attribute of the \a targetItem - * in the attribute extension \a target which has unique \a id to \a value. - */ - virtual void notifyExtendedAttributeChanged(int id, - const QString &target, - const QString &targetItem, - const QString &attribute, - const QVariant &value); - - /*! - * \brief Informs a list of clients that input method servers has changed the \a attribute of the \a targetItem - * in the attribute extension \a target which has unique \a id to \a value. - */ - virtual void notifyExtendedAttributeChanged(const QList &clientIds, - int id, - const QString &target, - const QString &targetItem, - const QString &attribute, - const QVariant &value); - Q_SIGNALS: /* Emitted first */ void contentOrientationAboutToChange(int angle); @@ -313,10 +286,6 @@ public Q_SLOTS: void widgetStateChanged(unsigned int clientId, const QMap &newState, const QMap &oldState, bool focusChanged); - void extendedAttributeChanged(unsigned int connectionId, int id, const QString &target, - const QString &targetName,const QString &attribute, const QVariant &value); - - void clientActivated(unsigned int connectionId); void clientDisconnected(unsigned int connectionId); void activeClientDisconnected(); diff --git a/dbus_interfaces/minputmethodcontext1interface.xml b/dbus_interfaces/minputmethodcontext1interface.xml index 90de0b59..86b2abb0 100644 --- a/dbus_interfaces/minputmethodcontext1interface.xml +++ b/dbus_interfaces/minputmethodcontext1interface.xml @@ -59,12 +59,5 @@ - - - - - - - diff --git a/dbus_interfaces/minputmethodserver1interface.xml b/dbus_interfaces/minputmethodserver1interface.xml index 75c75596..3f30d4b9 100644 --- a/dbus_interfaces/minputmethodserver1interface.xml +++ b/dbus_interfaces/minputmethodserver1interface.xml @@ -48,13 +48,6 @@ - - - - - - - diff --git a/input-context/minputcontext.cpp b/input-context/minputcontext.cpp index 7b189a43..dfe0df96 100644 --- a/input-context/minputcontext.cpp +++ b/input-context/minputcontext.cpp @@ -225,10 +225,6 @@ void MInputContext::update(Qt::InputMethodQueries queries) Q_UNUSED(queries) // fetching everything - if (queries & Qt::ImPlatformData) { - updateInputMethodExtensions(); - } - bool effectiveFocusChange = false; if (queries & Qt::ImEnabled) { bool newAcceptance = inputMethodAccepted(); @@ -260,8 +256,6 @@ void MInputContext::setFocusObject(QObject *focused) if (composeInputContext) composeInputContext->setFocusObject(focused); qCDebug(lcMaliit) << InputContextName << "in" << Q_FUNC_INFO << focused; - updateInputMethodExtensions(); - QWindow *newFocusWindow = qGuiApp->focusWindow(); if (newFocusWindow != window.data()) { if (window) { @@ -806,28 +800,3 @@ int MInputContext::cursorStartPosition(bool *valid) return start; } - -void MInputContext::updateInputMethodExtensions() -{ - if (!inputMethodAccepted()) { - return; - } - if (!qGuiApp->focusObject()) { - return; - } - qCDebug(lcMaliit) << InputContextName << Q_FUNC_INFO; - - QVariantMap extensions = qGuiApp->focusObject()->property("__inputMethodExtensions").toMap(); - QVariant value; - value = extensions.value("enterKeyIconSource"); - imServer->setExtendedAttribute(0, "/keys", "actionKey", "icon", QVariant(value.toUrl().toString())); - - value = extensions.value("enterKeyText"); - imServer->setExtendedAttribute(0, "/keys", "actionKey", "label", QVariant(value.toString())); - - value = extensions.value("enterKeyEnabled"); - imServer->setExtendedAttribute(0, "/keys", "actionKey", "enabled", value.isValid() ? value.toBool() : true); - - value = extensions.value("enterKeyHighlighted"); - imServer->setExtendedAttribute(0, "/keys", "actionKey", "highlighted", value.isValid() ? value.toBool() : false); -} diff --git a/input-context/minputcontext.h b/input-context/minputcontext.h index 4cd97e3a..ef7f56ba 100644 --- a/input-context/minputcontext.h +++ b/input-context/minputcontext.h @@ -114,8 +114,6 @@ private Q_SLOTS: void connectInputMethodServer(); - void updateInputMethodExtensions(); - // returns content type corresponding to specified hints Maliit::TextContentType contentType(Qt::InputMethodHints hints) const; diff --git a/maliit-glib/maliitattributeextensionregistry.c b/maliit-glib/maliitattributeextensionregistry.c index 9919a105..d8323dc1 100644 --- a/maliit-glib/maliitattributeextensionregistry.c +++ b/maliit-glib/maliitattributeextensionregistry.c @@ -272,19 +272,7 @@ maliit_attribute_extension_registry_extension_changed (MaliitAttributeExtensionR server = maliit_get_server_sync (NULL, &error); - if (server) { - if (!maliit_server_call_set_extended_attribute_sync (server, - maliit_attribute_extension_get_id (extension), - target, - parts[1], - parts[2], - value, - NULL, - &error)) { - g_warning ("Unable to set extended attribute: %s", error->message); - g_clear_error (&error); - } - } else { + if (!server) { g_warning ("Unable to connect to server: %s", error->message); g_clear_error (&error); } diff --git a/tests/ut_mimpluginmanager/ut_mimpluginmanager.cpp b/tests/ut_mimpluginmanager/ut_mimpluginmanager.cpp index d0f7ef30..b8c3adcb 100644 --- a/tests/ut_mimpluginmanager/ut_mimpluginmanager.cpp +++ b/tests/ut_mimpluginmanager/ut_mimpluginmanager.cpp @@ -58,25 +58,9 @@ namespace { class MInputContextTestConnection : public MInputContextConnection { public: - MInputContextTestConnection() : - notifyExtendedAttributeChanged_called(0) + MInputContextTestConnection() { } - - void notifyExtendedAttributeChanged(const QList &clientIds, int id, const QString &target, const QString &targetItem, const QString &attribute, const QVariant &value) - { - Q_UNUSED(id); - - notifyExtendedAttributeChanged_called++; - notifyExtendedAttributeChanged_clientIds = clientIds; - notifyExtendedAttributeChanged_key = QString("%1/%2/%3").arg(target).arg(targetItem).arg(attribute); - notifyExtendedAttributeChanged_value = value; - } - - int notifyExtendedAttributeChanged_called; - QList notifyExtendedAttributeChanged_clientIds; - QString notifyExtendedAttributeChanged_key; - QVariant notifyExtendedAttributeChanged_value; }; From 25cb39a627b2fb22b4acccf646469da11b1b6b5d Mon Sep 17 00:00:00 2001 From: Rodney Dawes Date: Mon, 13 Jun 2022 17:28:33 -0400 Subject: [PATCH 08/13] glib: Remove the plugin settings API from maliit-glib --- CMakeLists.txt | 25 +- maliit-glib/maliit-docs.xml | 4 - maliit-glib/maliit-glib-docs.pro | 87 --- maliit-glib/maliit-sections.txt | 91 --- maliit-glib/maliitattributeextension.c | 3 +- maliit-glib/maliitpluginsettings.c | 375 ----------- maliit-glib/maliitpluginsettings.h | 75 --- maliit-glib/maliitpluginsettingsprivate.h | 36 -- maliit-glib/maliitsettingdata.c | 251 -------- maliit-glib/maliitsettingdata.h | 87 --- maliit-glib/maliitsettingsentry.c | 605 ------------------ maliit-glib/maliitsettingsentry.h | 91 --- maliit-glib/maliitsettingsentryprivate.h | 36 -- maliit-glib/maliitsettingsmanager.c | 352 ---------- maliit-glib/maliitsettingsmanager.h | 75 --- tests/ut_maliit_glib_settings/.gitignore | 1 - .../mockmaliitserver.c | 164 ----- .../mockmaliitserver.h | 40 -- .../ut_maliit_glib_settings.c | 115 ---- 19 files changed, 2 insertions(+), 2511 deletions(-) delete mode 100644 maliit-glib/maliit-glib-docs.pro delete mode 100644 maliit-glib/maliitpluginsettings.c delete mode 100644 maliit-glib/maliitpluginsettings.h delete mode 100644 maliit-glib/maliitpluginsettingsprivate.h delete mode 100644 maliit-glib/maliitsettingdata.c delete mode 100644 maliit-glib/maliitsettingdata.h delete mode 100644 maliit-glib/maliitsettingsentry.c delete mode 100644 maliit-glib/maliitsettingsentry.h delete mode 100644 maliit-glib/maliitsettingsentryprivate.h delete mode 100644 maliit-glib/maliitsettingsmanager.c delete mode 100644 maliit-glib/maliitsettingsmanager.h delete mode 100644 tests/ut_maliit_glib_settings/.gitignore delete mode 100644 tests/ut_maliit_glib_settings/mockmaliitserver.c delete mode 100644 tests/ut_maliit_glib_settings/mockmaliitserver.h delete mode 100644 tests/ut_maliit_glib_settings/ut_maliit_glib_settings.c diff --git a/CMakeLists.txt b/CMakeLists.txt index 1a674e5e..2cbb47be 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -221,17 +221,7 @@ if(enable-glib) maliit-glib/maliitbus.h maliit-glib/maliitbusprivate.h maliit-glib/maliitinputmethod.c - maliit-glib/maliitinputmethod.h - maliit-glib/maliitpluginsettings.c - maliit-glib/maliitpluginsettings.h - maliit-glib/maliitpluginsettingsprivate.h - maliit-glib/maliitsettingdata.c - maliit-glib/maliitsettingdata.h - maliit-glib/maliitsettingsentry.c - maliit-glib/maliitsettingsentry.h - maliit-glib/maliitsettingsentryprivate.h - maliit-glib/maliitsettingsmanager.c - maliit-glib/maliitsettingsmanager.h) + maliit-glib/maliitinputmethod.h) set_source_files_properties(maliit-glib/maliitmarshallers.list PROPERTIES PREFIX maliit_marshal) @@ -532,19 +522,6 @@ if(enable-tests) TESTDATA_PATH=${CMAKE_SOURCE_DIR}/tests QT_QPA_PLATFORM=minimal) - if(enable-glib) - add_executable(ut_maliit_glib_settings - tests/ut_maliit_glib_settings/ut_maliit_glib_settings.c - tests/ut_maliit_glib_settings/mockmaliitserver.c - tests/ut_maliit_glib_settings/mockmaliitserver.h) - target_link_libraries(ut_maliit_glib_settings GLib2::GLib GLib2::GIO maliit-glib) - - add_test(ut_maliit_glib_settings ut_maliit_glib_settings) - if(install-tests) - install(TARGETS ut_maliit_glib_settings DESTINATION ${CMAKE_INSTALL_LIBDIR}/maliit-framework-tests/ut_maliit_glib_settings) - endif() - endif() - if(install-tests) install(FILES tests/qmlplugin/helloworld.qml DESTINATION ${CMAKE_INSTALL_LIBDIR}/maliit-framework-tests/plugins/qml/helloworld) diff --git a/maliit-glib/maliit-docs.xml b/maliit-glib/maliit-docs.xml index b5543b37..37b9d60a 100644 --- a/maliit-glib/maliit-docs.xml +++ b/maliit-glib/maliit-docs.xml @@ -18,10 +18,6 @@ Maliit - - - - diff --git a/maliit-glib/maliit-glib-docs.pro b/maliit-glib/maliit-glib-docs.pro deleted file mode 100644 index 1c3b1546..00000000 --- a/maliit-glib/maliit-glib-docs.pro +++ /dev/null @@ -1,87 +0,0 @@ -TOP_DIR = .. - -include(../config.pri) - -TEMPLATE=lib -TARGET=dummy - -GOBJECTFILES += \ - maliitattributeextension.c \ - maliitattributeextension.h \ - maliitinputmethod.c \ - maliitinputmethod.h \ - maliitsettingsmanager.c \ - maliitsettingsmanager.h \ - maliitsettingsentry.c \ - maliitsettingsentry.h \ - maliitpluginsettings.c \ - maliitpluginsettings.h \ - maliitsettingdata.c \ - maliitsettingdata.h \ - - -LIB_DIR = $$OUT_PWD/$$TOP_DIR/lib - -# The resulting html docs go into ./maliit, and the temporary build files to ./reference/ -gtk_doc.name = gtk-doc -gtk_doc.CONFIG += target_predeps no_link combine -gtk_doc.output = $${OUT_PWD}/maliit/index.html -gtk_doc.clean_commands = rm -rf $${OUT_PWD}/maliit $${OUT_PWD}/reference -gtk_doc.input = GOBJECTFILES -gtk_doc.commands += mkdir -p reference && -gtk_doc.commands += cp $$PWD/maliit-sections.txt $$PWD/maliit-docs.xml $$OUT_PWD/reference && -gtk_doc.commands += cd reference && -gtk_doc.commands += gtkdoc-scan --module=maliit --source-dir=$${PWD} --rebuild-types && -gtk_doc.commands += LD_LIBRARY_PATH=\"$${LIB_DIR}\" CFLAGS=\"$$system(pkg-config --cflags gio-2.0)\" LDFLAGS=\"-L$${LIB_DIR} -l$${MALIIT_GLIB_LIB} $$system(pkg-config --libs gio-2.0)\" -gtk_doc.commands += gtkdoc-scangobj --module=maliit && -gtk_doc.commands += gtkdoc-mkdb --module=maliit --source-dir=$${PWD} --output-format=xml && cd .. && -gtk_doc.commands += mkdir -p maliit && cd maliit && gtkdoc-mkhtml maliit ../reference/maliit-docs.xml && cd .. && -gtk_doc.commands += cd reference && gtkdoc-fixxref --module=maliit --module-dir=../maliit && cd .. - -gir_scanner.name = g-ir-scanner -gir_scanner.CONFIG += no_link combine -gir_scanner.output = $${OUT_PWD}/Maliit-1.0.gir -gir_scanner.input = GOBJECTFILES -gir_scanner.commands += LD_LIBRARY_PATH=\"$${LIB_DIR}\" g-ir-scanner --warn-all -n Maliit --no-libtool -L$${LIB_DIR} --library=maliit-glib --include=Gio-2.0 --pkg=gio-2.0 --pkg-export=maliit-glib-1.0 --nsversion=1.0 --output=${QMAKE_FILE_OUT} ${QMAKE_FILE_IN} - -GIR_FILES = $${OUT_PWD}/Maliit-1.0.gir - -gir_compiler.name = g-ir-compiler -gir_compiler.CONFIG += target_predeps no_link no_check_exist -gir_compiler.output = $${OUT_PWD}/Maliit-1.0.typelib -gir_compiler.input = GIR_FILES -gir_compiler.commands += g-ir-compiler -m Maliit --output=${QMAKE_FILE_OUT} ${QMAKE_FILE_IN} - -system(pkg-config gtk-doc) { - docs.files = $${OUT_PWD}/maliit - docs.path = $$DATADIR/gtk-doc/html - docs.CONFIG += no_check_exist directory - - INSTALLS += docs - - QMAKE_EXTRA_COMPILERS += gtk_doc -} - -system(pkg-config gobject-introspection-1.0) { - GIR_DIR = $$system(pkg-config --variable=girdir gobject-introspection-1.0) - TYPELIB_DIR = $$system(pkg-config --variable=typelibdir gobject-introspection-1.0) - GIR_PREFIX = $$system(pkg-config --variable=prefix gobject-introspection-1.0) - local-install { - GIR_DIR = $$replace(GIR_DIR, $$GIR_PREFIX, $$PREFIX) - TYPELIB_DIR = $$replace(TYPELIB_DIR, $$GIR_PREFIX, $$PREFIX) - } - - gir.files = $${OUT_PWD}/Maliit-1.0.gir - gir.path = $$GIR_DIR - gir.CONFIG += no_check_exist - - typelib.files = $${OUT_PWD}/Maliit-1.0.typelib - typelib.path = $$TYPELIB_DIR - typelib.CONFIG += no_check_exist - - INSTALLS += gir typelib - - QMAKE_EXTRA_COMPILERS += gir_scanner gir_compiler -} - -OTHER_FILES += maliit-sections.txt maliit-docs.xml diff --git a/maliit-glib/maliit-sections.txt b/maliit-glib/maliit-sections.txt index 20cf607e..42599c26 100644 --- a/maliit-glib/maliit-sections.txt +++ b/maliit-glib/maliit-sections.txt @@ -73,97 +73,6 @@ MaliitInputMethodPrivate maliit_input_method_get_type -
-maliitsettingsmanager -MaliitSectionManager -MaliitSettingsManager -MaliitSettingsManagerClass -maliit_settings_manager_new -maliit_settings_manager_get_preferred_description_locale -maliit_settings_manager_load_plugin_settings -maliit_settings_manager_set_preferred_description_locale - -MALIIT_SETTINGS_MANAGER -MALIIT_SETTINGS_MANAGER_CLASS -MALIIT_SETTINGS_MANAGER_GET_CLASS -MALIIT_IS_SETTINGS_MANAGER -MALIIT_IS_SETTINGS_MANAGER_CLASS -MALIIT_TYPE_SETTINGS_MANAGER -MaliitSettingsManagerPrivate -maliit_settings_manager_get_type -
- -
-maliitsettingsentry -MaliitSettingsEntry -MaliitSettingsEntry -MaliitSettingsEntryClass -maliit_settings_entry_get_attributes -maliit_settings_entry_get_description -maliit_settings_entry_get_entry_type -maliit_settings_entry_get_key -maliit_settings_entry_get_value -maliit_settings_entry_is_value_valid -maliit_settings_entry_set_value -maliit_settings_entry_is_current_value_valid - -MALIIT_IS_SETTINGS_ENTRY -MALIIT_IS_SETTINGS_ENTRY_CLASS -MALIIT_SETTINGS_ENTRY -MALIIT_SETTINGS_ENTRY_CLASS -MALIIT_SETTINGS_ENTRY_GET_CLASS -MALIIT_TYPE_SETTINGS_ENTRY -MaliitSettingsEntryPrivate -maliit_settings_entry_get_type -
- -
- -maliitsettingsentryprivate -maliit_settings_entry_new_from_dbus_data -
- -
-maliitpluginsettings -MaliitPluginSettings -MaliitPluginSettings -MaliitPluginSettingsClass -maliit_plugin_settings_get_configuration_entries -maliit_plugin_settings_get_description_language -maliit_plugin_settings_get_plugin_description -maliit_plugin_settings_get_plugin_name - -MALIIT_IS_PLUGIN_SETTINGS -MALIIT_IS_PLUGIN_SETTINGS_CLASS -MALIIT_PLUGIN_SETTINGS -MALIIT_PLUGIN_SETTINGS_CLASS -MALIIT_PLUGIN_SETTINGS_GET_CLASS -MALIIT_TYPE_PLUGIN_SETTINGS -MaliitPluginSettingsPrivate -maliit_plugin_settings_get_type -
- -
- -maliitpluginsettingsprivate -maliit_plugin_settings_new_from_dbus_data -
- -
-maliitsettingdata -Maliit setting data -MaliitSettingsEntryType -MALIIT_SETTING_DEFAULT_VALUE -MALIIT_SETTING_VALUE_DOMAIN -MALIIT_SETTING_VALUE_DOMAIN_DESCRIPTIONS -MALIIT_SETTING_VALUE_RANGE_MAX -MALIIT_SETTING_VALUE_RANGE_MIN -maliit_validate_setting_value - -MALIIT_TYPE_SETTINGS_ENTRY_TYPE -maliit_settings_entry_type_get_type -
-
maliitmarshallers diff --git a/maliit-glib/maliitattributeextension.c b/maliit-glib/maliitattributeextension.c index 91e775be..72c90a0f 100644 --- a/maliit-glib/maliitattributeextension.c +++ b/maliit-glib/maliitattributeextension.c @@ -284,8 +284,7 @@ maliit_attribute_extension_new (void) * maliit_attribute_extension_new_with_id: (skip) * @id: An overriden id. * - * Creates a new attribute extension with already existing id. Used - * internally by #MaliitSettingsManager. + * Creates a new attribute extension with already existing id. * * Returns: (transfer full): The newly created * #MaliitAttributeExtension. diff --git a/maliit-glib/maliitpluginsettings.c b/maliit-glib/maliitpluginsettings.c deleted file mode 100644 index 9b8137d1..00000000 --- a/maliit-glib/maliitpluginsettings.c +++ /dev/null @@ -1,375 +0,0 @@ -/* This file is part of Maliit framework - * - * Copyright (C) 2012 Canonical Ltd - * - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the licence, or (at your option) any later version. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include "maliitpluginsettingsprivate.h" -#include "maliitsettingsentryprivate.h" - -/** - * SECTION:maliitpluginsettings - * @short_description: plugin settings - * @title: MaliitPluginSettings - * @see_also: #MaliitSettingsEntry, #MaliitSettingsManager - * @stability: Stable - * @include: maliit/maliitpluginsettings.h - * - * The #MaliitPluginSettings is a class holding general plugin - * information like name, description and configuration entries. - */ - -struct _MaliitPluginSettingsPrivate -{ - gchar *description_language; - gchar *plugin_name; - gchar *plugin_description; - GPtrArray *entries; -}; - -G_DEFINE_TYPE_WITH_CODE (MaliitPluginSettings, maliit_plugin_settings, - G_TYPE_OBJECT, G_ADD_PRIVATE (MaliitPluginSettings)) - -enum -{ - PROP_0, - - PROP_DESCRIPTION_LANGUAGE, - PROP_PLUGIN_NAME, - PROP_PLUGIN_DESCRIPTION, - PROP_CONFIGURATION_ENTRIES -}; - -static void -maliit_plugin_settings_finalize (GObject *object) -{ - MaliitPluginSettings *settings = MALIIT_PLUGIN_SETTINGS (object); - MaliitPluginSettingsPrivate *priv = settings->priv; - - g_free (priv->description_language); - g_free (priv->plugin_name); - g_free (priv->plugin_description); - - G_OBJECT_CLASS (maliit_plugin_settings_parent_class)->finalize (object); -} - -static void -maliit_plugin_settings_dispose (GObject *object) -{ - MaliitPluginSettings *settings = MALIIT_PLUGIN_SETTINGS (object); - MaliitPluginSettingsPrivate *priv = settings->priv; - - if (priv->entries) { - GPtrArray *entries = priv->entries; - - priv->entries = NULL; - g_ptr_array_unref (entries); - } - - G_OBJECT_CLASS (maliit_plugin_settings_parent_class)->dispose (object); -} - -static void -maliit_plugin_settings_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) -{ - MaliitPluginSettings *settings = MALIIT_PLUGIN_SETTINGS (object); - MaliitPluginSettingsPrivate *priv = settings->priv; - - switch (prop_id) { - case PROP_DESCRIPTION_LANGUAGE: - g_free (priv->description_language); - priv->description_language = g_value_dup_string (value); - break; - case PROP_PLUGIN_NAME: - g_free (priv->plugin_name); - priv->plugin_name = g_value_dup_string (value); - break; - case PROP_PLUGIN_DESCRIPTION: - g_free (priv->plugin_description); - priv->plugin_description = g_value_dup_string (value); - break; - case PROP_CONFIGURATION_ENTRIES: - if (priv->entries) { - g_ptr_array_unref (priv->entries); - } - priv->entries = g_value_dup_boxed (value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -maliit_plugin_settings_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - MaliitPluginSettings *settings = MALIIT_PLUGIN_SETTINGS (object); - MaliitPluginSettingsPrivate *priv = settings->priv; - - switch (prop_id) { - case PROP_DESCRIPTION_LANGUAGE: - g_value_set_string (value, priv->description_language); - break; - case PROP_PLUGIN_NAME: - g_value_set_string (value, priv->plugin_name); - break; - case PROP_PLUGIN_DESCRIPTION: - g_value_set_string (value, priv->plugin_description); - break; - case PROP_CONFIGURATION_ENTRIES: - g_value_set_boxed (value, priv->entries); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -maliit_plugin_settings_class_init (MaliitPluginSettingsClass *settings_class) -{ - GObjectClass *g_object_class = G_OBJECT_CLASS (settings_class); - - g_object_class->finalize = maliit_plugin_settings_finalize; - g_object_class->dispose = maliit_plugin_settings_dispose; - g_object_class->set_property = maliit_plugin_settings_set_property; - g_object_class->get_property = maliit_plugin_settings_get_property; - - /** - * MaliitPluginSettings:description-language: - * - * Language of the plugin description. - */ - g_object_class_install_property (g_object_class, - PROP_DESCRIPTION_LANGUAGE, - g_param_spec_string ("description-language", - "Description language", /* TODO: mark as translatable? */ - "Language of the plugin description", /* TODO: mark as translatable? */ - "en", - G_PARAM_READABLE | - G_PARAM_WRITABLE | - G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_NAME | - G_PARAM_STATIC_BLURB | - G_PARAM_STATIC_NICK)); - - /** - * MaliitPluginSettings:plugin-name: - * - * Name of the plugin. - */ - g_object_class_install_property (g_object_class, - PROP_PLUGIN_NAME, - g_param_spec_string ("plugin-name", - "Plugin name", /* TODO: mark as translatable? */ - "Name of the plugin", /* TODO: mark as translatable? */ - "unknown", - G_PARAM_READABLE | - G_PARAM_WRITABLE | - G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_NAME | - G_PARAM_STATIC_BLURB | - G_PARAM_STATIC_NICK)); - - /** - * MaliitPluginSettings:plugin-description: - * - * Description of the plugin. - */ - g_object_class_install_property (g_object_class, - PROP_PLUGIN_DESCRIPTION, - g_param_spec_string ("plugin-description", - "Plugin description", /* TODO: mark as translatable? */ - "Description of the plugin", /* TODO: mark as translatable? */ - "", - G_PARAM_READABLE | - G_PARAM_WRITABLE | - G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_NAME | - G_PARAM_STATIC_BLURB | - G_PARAM_STATIC_NICK)); - - /* TODO: this property appears as array of gpointers in gir file. - * I have no clue how to fix it. - */ - /** - * MaliitPluginSettings:configuration-entries: (element-type Maliit.SettingsEntry) - * - * List of configuration entries of the plugin. - */ - g_object_class_install_property (g_object_class, - PROP_CONFIGURATION_ENTRIES, - g_param_spec_boxed ("configuration-entries", - "Configuration entries", /* TODO: mark as translatable? */ - "List of configuration entries of the plugin", /* TODO: mark as translatable? */ - G_TYPE_PTR_ARRAY, - G_PARAM_READABLE | - G_PARAM_WRITABLE | - G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_NAME | - G_PARAM_STATIC_BLURB | - G_PARAM_STATIC_NICK)); -} - -static void -maliit_plugin_settings_init (MaliitPluginSettings *settings) -{ - MaliitPluginSettingsPrivate *priv = maliit_plugin_settings_get_instance_private (settings); - - priv->description_language = NULL; - priv->plugin_name = NULL; - priv->plugin_description = NULL; - priv->entries = NULL; - - settings->priv = priv; -} - -static GPtrArray * -configuration_entries_from_dbus_g_variant (GVariant *dbus_entries, - MaliitAttributeExtension *extension) -{ - GPtrArray *configuration_entries = g_ptr_array_sized_new (g_variant_n_children (dbus_entries)); - guint iter; - - g_ptr_array_set_free_func (configuration_entries, g_object_unref); - for (iter = 0; iter < g_variant_n_children (dbus_entries); ++iter) { - GVariant *info = g_variant_get_child_value (dbus_entries, iter); - - g_ptr_array_add (configuration_entries, - maliit_settings_entry_new_from_dbus_data (info, - extension)); - - g_variant_unref (info); - } - return configuration_entries; -} - -/** - * maliit_plugin_settings_new_from_dbus_data: (skip) - * @plugin_info: A #GVariant of DBus provenance containing plugin information. - * @extension: A #MaliitAttributeExtensions for #MaliitAttributeSettingsEntry instances. - * - * Creates new settings settings. This is used internally only by - * #MaliitSettingsManager. - * - * Returns: The newly created #MaliitPluginSettings. - */ -MaliitPluginSettings * -maliit_plugin_settings_new_from_dbus_data (GVariant *plugin_info, - MaliitAttributeExtension *extension) -{ - const gchar *description_language; - const gchar *plugin_name; - const gchar *plugin_description; - GVariant *plugin_entries; - GPtrArray *configuration_entries; - MaliitPluginSettings *settings; - - g_return_val_if_fail (MALIIT_IS_ATTRIBUTE_EXTENSION (extension), NULL); - - g_variant_get (plugin_info, - "(&s&s&si@a(ssibva{sv}))", - &description_language, - &plugin_name, - &plugin_description, - NULL, - &plugin_entries); - - configuration_entries = configuration_entries_from_dbus_g_variant (plugin_entries, extension); - settings = MALIIT_PLUGIN_SETTINGS (g_object_new (MALIIT_TYPE_PLUGIN_SETTINGS, - "description-language", description_language, - "plugin-name", plugin_name, - "plugin-description", plugin_description, - "configuration-entries", configuration_entries, - NULL)); - - g_ptr_array_unref (configuration_entries); - g_variant_unref (plugin_entries); - - return settings; -} - -/** - * maliit_plugin_settings_get_description_language: - * @settings: (transfer none): The #MaliitPluginSettings. - * - * Gets language of the plugin description. - * - * Returns: (transfer none): A language. Returned value should not be modified nor freed. - */ -const gchar * -maliit_plugin_settings_get_description_language (MaliitPluginSettings *settings) -{ - g_return_val_if_fail (MALIIT_IS_PLUGIN_SETTINGS (settings), NULL); - - return settings->priv->description_language; -} - -/** - * maliit_plugin_settings_get_plugin_name: - * @settings: (transfer none): The #MaliitPluginSettings. - * - * Gets name of the plugin. - * - * Returns: (transfer none): A name. Returned value should not be modified nor freed. - */ -const gchar * -maliit_plugin_settings_get_plugin_name (MaliitPluginSettings *settings) -{ - g_return_val_if_fail (MALIIT_IS_PLUGIN_SETTINGS (settings), NULL); - - return settings->priv->plugin_name; -} - -/** - * maliit_plugin_settings_get_plugin_description: - * @settings: (transfer none): The #MaliitPluginSettings. - * - * Gets description of the plugin. - * - * Returns: (transfer none): A description. Returned value should not be modified nor freed. - */ -const gchar * -maliit_plugin_settings_get_plugin_description (MaliitPluginSettings *settings) -{ - g_return_val_if_fail (MALIIT_IS_PLUGIN_SETTINGS (settings), NULL); - - return settings->priv->plugin_description; -} - -/** - * maliit_plugin_settings_get_configuration_entries: - * @settings: (transfer none): The #MaliitPluginSettings. - * - * Gets configuration entries of the plugin - * - * Returns: (transfer none) (element-type Maliit.SettingsEntry): Configuration entries. Returned value should not be modified nor freed. - */ -GPtrArray * -maliit_plugin_settings_get_configuration_entries (MaliitPluginSettings *settings) -{ - g_return_val_if_fail (MALIIT_IS_PLUGIN_SETTINGS (settings), NULL); - - return settings->priv->entries; -} diff --git a/maliit-glib/maliitpluginsettings.h b/maliit-glib/maliitpluginsettings.h deleted file mode 100644 index 44063cb2..00000000 --- a/maliit-glib/maliitpluginsettings.h +++ /dev/null @@ -1,75 +0,0 @@ -/* This file is part of Maliit framework - * - * Copyright (C) 2012 Canonical Ltd - * - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the licence, or (at your option) any later version. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef MALIIT_GLIB_PLUGIN_SETTINGS_H -#define MALIIT_GLIB_PLUGIN_SETTINGS_H - -#include -#include - -G_BEGIN_DECLS - -#define MALIIT_TYPE_PLUGIN_SETTINGS (maliit_plugin_settings_get_type()) -#define MALIIT_PLUGIN_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_CAST(obj, MALIIT_TYPE_PLUGIN_SETTINGS, MaliitPluginSettings)) -#define MALIIT_PLUGIN_SETTINGS_CLASS(cls) (G_TYPE_CHECK_CLASS_CAST(cls, MALIIT_TYPE_PLUGIN_SETTINGS, MaliitPluginSettingsClass)) -#define MALIIT_IS_PLUGIN_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_TYPE(obj, MALIIT_TYPE_PLUGIN_SETTINGS)) -#define MALIIT_IS_PLUGIN_SETTINGS_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE(obj, MALIIT_TYPE_PLUGIN_SETTINGS)) -#define MALIIT_PLUGIN_SETTINGS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), MALIIT_TYPE_PLUGIN_SETTINGS, MaliitPluginSettingsClass)) - -typedef struct _MaliitPluginSettings MaliitPluginSettings; -typedef struct _MaliitPluginSettingsClass MaliitPluginSettingsClass; -typedef struct _MaliitPluginSettingsPrivate MaliitPluginSettingsPrivate; - -struct _MaliitPluginSettings -{ - GObject parent; - - /*< private >*/ - MaliitPluginSettingsPrivate *priv; -}; - -/** - * MaliitPluginSettingsClass: - * @parent_class: The parent class. - */ -struct _MaliitPluginSettingsClass -{ - GObjectClass parent_class; -}; - -GType -maliit_plugin_settings_get_type (void) G_GNUC_CONST; - -const gchar * -maliit_plugin_settings_get_description_language (MaliitPluginSettings *settings); - -const gchar * -maliit_plugin_settings_get_plugin_name (MaliitPluginSettings *settings); - -const gchar * -maliit_plugin_settings_get_plugin_description (MaliitPluginSettings *settings); - -GPtrArray * -maliit_plugin_settings_get_configuration_entries (MaliitPluginSettings *settings); - -G_END_DECLS - -#endif /* MALIIT_GLIB_PLUGIN_SETTINGS_H */ diff --git a/maliit-glib/maliitpluginsettingsprivate.h b/maliit-glib/maliitpluginsettingsprivate.h deleted file mode 100644 index 54993ccc..00000000 --- a/maliit-glib/maliitpluginsettingsprivate.h +++ /dev/null @@ -1,36 +0,0 @@ -/* This file is part of Maliit framework - * - * Copyright (C) 2012 Canonical Ltd - * - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the licence, or (at your option) any later version. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef MALIIT_GLIB_PLUGIN_SETTINGS_PRIVATE_H -#define MALIIT_GLIB_PLUGIN_SETTINGS_PRIVATE_H - -#include "maliitattributeextension.h" -#include "maliitpluginsettings.h" - -G_BEGIN_DECLS - -MaliitPluginSettings * -maliit_plugin_settings_new_from_dbus_data (GVariant *plugin_info, - MaliitAttributeExtension *extension); - -G_END_DECLS - -#endif /* MALIIT_GLIB_PLUGIN_SETTINGS_PRIVATE_H */ diff --git a/maliit-glib/maliitsettingdata.c b/maliit-glib/maliitsettingdata.c deleted file mode 100644 index 1279e1d7..00000000 --- a/maliit-glib/maliitsettingdata.c +++ /dev/null @@ -1,251 +0,0 @@ -/* This file is part of Maliit framework - * - * Copyright (C) 2012 Canonical Ltd - * - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the licence, or (at your option) any later version. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include "maliitsettingdata.h" - -/** - * SECTION:maliitsettingdata - * @short_description: miscellaneous setting functions and types - * @title: Maliit settings misc - * @see_also: #MaliitSettingsEntry, #MaliitPluginSettings - * @stability: Stable - * @include: maliit/maliitsettingdata.h - * - * Here #MaliitSettingsEntryType, attribute keys and - * maliit_validate_setting_value() are specified. - */ - - -/** - * MaliitSettingsEntryType: - * @MALIIT_STRING_TYPE: Entry is a string. - * @MALIIT_INT_TYPE: Entry is an integer. - * @MALIIT_BOOL_TYPE: Entry is a boolean. - * @MALIIT_STRING_LIST_TYPE: Entry is a list of strings. - * @MALIIT_INT_LIST_TYPE: Entry is a list of integers. - * - * This enum describes type of settings entry. - */ -static const GEnumValue maliit_settings_entry_type_values[] = { - { MALIIT_STRING_TYPE, "MALIIT_STRING_TYPE", "string-type" }, - { MALIIT_INT_TYPE, "MALIIT_INT_TYPE", "int-type" }, - { MALIIT_BOOL_TYPE, "MALIIT_BOOL_TYPE", "bool-type" }, - { MALIIT_STRING_LIST_TYPE, "MALIIT_STRING_LIST_TYPE", "string-list-type" }, - { MALIIT_INT_LIST_TYPE, "MALIIT_INT_LIST_TYPE", "int-list-type" }, - { 0, NULL, NULL } -}; - -GType -maliit_settings_entry_type_get_type (void) -{ - static GType type = G_TYPE_INVALID; - - if (type == G_TYPE_INVALID) { - type = g_enum_register_static ("MaliitSettingsEntryType", - maliit_settings_entry_type_values); - } - - return type; -} - -static gboolean -check_single_value_domain(GVariant *value, - GVariant *domain) -{ - gsize array_len = g_variant_n_children(domain); - gboolean equal = FALSE; - gsize iter; - - for (iter = 0; iter < array_len && !equal; ++iter) { - GVariant *child = g_variant_get_child_value(domain, iter); - - equal = g_variant_equal(value, child); - g_variant_unref(child); - } - return equal; -} - -static gboolean -check_variant_value_domain(GVariant *value, - GVariant *domain) -{ - if (!domain) { - return TRUE; - } - - if (!g_variant_is_of_type(domain, G_VARIANT_TYPE_ARRAY)) { - return FALSE; - } - - return check_single_value_domain(value, domain); -} - -static gboolean -check_variant_array_domain(GVariant *values, GVariant *domain) -{ - gsize iter; - gsize array_len; - gboolean correct; - - if (!domain) { - return TRUE; - } - - if (!g_variant_is_of_type(domain, G_VARIANT_TYPE_ARRAY)) { - return FALSE; - } - - array_len = g_variant_n_children(values); - correct = TRUE; - for (iter = 0; iter < array_len && correct; ++iter) { - GVariant *child = g_variant_get_child_value(values, iter); - - correct = check_single_value_domain(child, domain); - g_variant_unref (child); - } - return correct; -} - -static gboolean -check_single_value_range(GVariant *value, - GVariant *range_min, - GVariant *range_max) -{ - if (range_min) { - if (!g_variant_is_of_type(range_min, G_VARIANT_TYPE_INT32) || - g_variant_get_int32(range_min) > g_variant_get_int32(value)) { - return FALSE; - } - } - - if (range_max) { - if (!g_variant_is_of_type(range_max, G_VARIANT_TYPE_INT32) || - g_variant_get_int32(range_max) < g_variant_get_int32(value)) { - return FALSE; - } - } - - return TRUE; -} - -static gboolean -check_variant_value_range(GVariant *value, - GVariant *range_min, - GVariant *range_max) -{ - if (!range_min && !range_max) { - return TRUE; - } - - return check_single_value_range(value, range_min, range_max); -} - -static gboolean -check_variant_array_range(GVariant *values, - GVariant *range_min, - GVariant *range_max) -{ - gsize iter; - gsize values_len; - gboolean correct; - - if (!range_min && !range_max) { - return TRUE; - } - - correct = TRUE; - values_len = g_variant_n_children(values); - for (iter = 0; iter < values_len && correct; ++iter) { - GVariant *child = g_variant_get_child_value(values, iter); - - correct = check_single_value_range(child, range_min, range_max); - g_variant_unref (child); - } - - return correct; -} - -static gboolean -check_variant_array_is_int_array(GVariant *values) -{ - gsize array_len = g_variant_n_children(values); - gsize iter; - gboolean correct = TRUE; - - for (iter = 0; iter < array_len && correct; ++iter) { - GVariant *child = g_variant_get_child_value(values, iter); - - correct = g_variant_is_of_type(child, G_VARIANT_TYPE_INT32); - g_variant_unref(child); - } - return correct; -} - -/** - * maliit_validate_setting_value: - * @type: a #MaliitSettingsEntryType to validate against. - * @attributes: (transfer none) (element-type utf8 GLib.Variant): Attributes to validate. - * @value: (transfer none): A #GVariant to validate. - * - * Validate the value for a plugin setting entry. - * - * Returns: %TRUE if @value and @attributes are valid for given @type. - */ -gboolean -maliit_validate_setting_value(MaliitSettingsEntryType type, - GHashTable *attributes, - GVariant *value) -{ - GVariant *domain = g_hash_table_lookup(attributes, - MALIIT_SETTING_VALUE_DOMAIN); - GVariant *range_min = g_hash_table_lookup(attributes, - MALIIT_SETTING_VALUE_RANGE_MIN); - GVariant *range_max = g_hash_table_lookup(attributes, - MALIIT_SETTING_VALUE_RANGE_MAX); - - switch (type) - { - case MALIIT_STRING_TYPE: - return (g_variant_is_of_type(value, G_VARIANT_TYPE_STRING) && - check_variant_value_domain(value, domain)); - - case MALIIT_INT_TYPE: - return (g_variant_is_of_type(value, G_VARIANT_TYPE_INT32) && - check_variant_value_domain(value, domain) && - check_variant_value_range(value, range_min, range_max)); - - case MALIIT_BOOL_TYPE: - return g_variant_is_of_type(value, G_VARIANT_TYPE_BOOLEAN); - - case MALIIT_STRING_LIST_TYPE: - return (g_variant_is_of_type(value, G_VARIANT_TYPE_STRING_ARRAY) && - check_variant_array_domain(value, domain)); - - case MALIIT_INT_LIST_TYPE: - return (g_variant_is_of_type(value, G_VARIANT_TYPE_ARRAY) && - check_variant_array_is_int_array(value) && - check_variant_array_domain(value, domain) && - check_variant_array_range(value, range_min, range_max)); - - default: - return FALSE; - } -} diff --git a/maliit-glib/maliitsettingdata.h b/maliit-glib/maliitsettingdata.h deleted file mode 100644 index c8838c3a..00000000 --- a/maliit-glib/maliitsettingdata.h +++ /dev/null @@ -1,87 +0,0 @@ -/* This file is part of Maliit framework - * - * Copyright (C) 2012 Canonical Ltd - * - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the licence, or (at your option) any later version. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef MALIIT_GLIB_SETTING_DATA_H -#define MALIIT_GLIB_SETTING_DATA_H - -#include -#include - -G_BEGIN_DECLS - -typedef enum -{ - MALIIT_STRING_TYPE = 1, - MALIIT_INT_TYPE = 2, - MALIIT_BOOL_TYPE = 3, - MALIIT_STRING_LIST_TYPE = 4, - MALIIT_INT_LIST_TYPE = 5 -} MaliitSettingsEntryType; - -/** - * MALIIT_SETTING_VALUE_DOMAIN: - * - * Name of setting entry attribute which holds the list of values that - * can be assigned to the entry. - */ -#define MALIIT_SETTING_VALUE_DOMAIN "valueDomain" - -/** - * MALIIT_SETTING_VALUE_DOMAIN_DESCRIPTIONS: - * - * Name of setting entry attribute which holds the descriptions for - * the values in MALIIT_SETTING_VALUE_DOMAIN(). - */ -#define MALIIT_SETTING_VALUE_DOMAIN_DESCRIPTIONS "valueDomainDescriptions" - -/** - * MALIIT_SETTING_VALUE_RANGE_MIN: - * - * Name of setting entry attribute which holds the minimum valid value - * (inclusive) for an integer property. - */ -#define MALIIT_SETTING_VALUE_RANGE_MIN "valueRangeMin" -/** - * MALIIT_SETTING_VALUE_RANGE_MAX: - * - * Name of setting entry attribute which holds the maximum valid value - * (inclusive) for an integer property. - */ -#define MALIIT_SETTING_VALUE_RANGE_MAX "valueRangeMax" - -/** - * MALIIT_SETTING_DEFAULT_VALUE: - * - * Name of setting entry attribute which holds the default value for a setting entry. - */ -#define MALIIT_SETTING_DEFAULT_VALUE "defaultValue" - -#define MALIIT_TYPE_SETTINGS_ENTRY_TYPE maliit_settings_entry_type_get_type () -GType maliit_settings_entry_type_get_type (void) G_GNUC_CONST; - -gboolean -maliit_validate_setting_value(MaliitSettingsEntryType type, - GHashTable *attributes, - GVariant *value); - -G_END_DECLS - -#endif /* MALIIT_GLIB_SETTING_DATA_H */ diff --git a/maliit-glib/maliitsettingsentry.c b/maliit-glib/maliitsettingsentry.c deleted file mode 100644 index 50757e76..00000000 --- a/maliit-glib/maliitsettingsentry.c +++ /dev/null @@ -1,605 +0,0 @@ -/* This file is part of Maliit framework - * - * Copyright (C) 2012 Canonical Ltd - * - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the licence, or (at your option) any later version. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include "maliitpluginsettingsprivate.h" -#include "maliitsettingsentryprivate.h" - -/** - * SECTION:maliitsettingsentry - * @short_description: settings entry - * @title: MaliitSettingsEntry - * @see_also: #MaliitSettingsEntry, #MaliitPluginSettings - * @stability: Stable - * @include: maliit/maliitsettingsentry.h - * - * The #MaliitSettingsEntry is a class holding single plugin - * setting. It can be one of several available types - * (#MaliitSettingsEntryType). It can also have some attributes like - * value domain (MALIIT_SETTING_VALUE_DOMAIN()), default value - * (MALIIT_SETTING_DEFAULT_VALUE) and value ranges - * (MALIIT_SETTING_VALUE_RANGE_MIN() and - * MALIIT_SETTING_VALUE_RANGE_MAX()). - */ - -struct _MaliitSettingsEntryPrivate -{ - MaliitAttributeExtension *extension; - gchar *description; - gchar *extension_key; - MaliitSettingsEntryType type; - gboolean valid; - GHashTable *attributes; - - guint extension_signal_id; -}; - -G_DEFINE_TYPE_WITH_CODE (MaliitSettingsEntry, maliit_settings_entry, - G_TYPE_OBJECT, G_ADD_PRIVATE(MaliitSettingsEntry)) - -enum -{ - PROP_0, - - PROP_EXTENSION, - PROP_DESCRIPTION, - PROP_EXTENSION_KEY, - PROP_TYPE, - PROP_VALID, - PROP_VALUE, - PROP_ATTRIBUTES -}; - -enum -{ - VALUE_CHANGED, - - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = { 0 }; - -static void -maliit_settings_entry_finalize (GObject *object) -{ - MaliitSettingsEntry *entry = MALIIT_SETTINGS_ENTRY (object); - MaliitSettingsEntryPrivate *priv = entry->priv; - - g_free (priv->description); - g_free (priv->extension_key); - - G_OBJECT_CLASS (maliit_settings_entry_parent_class)->finalize (object); -} - -static void -maliit_settings_entry_dispose (GObject *object) -{ - MaliitSettingsEntry *entry = MALIIT_SETTINGS_ENTRY (object); - MaliitSettingsEntryPrivate *priv = entry->priv; - - if (priv->extension_signal_id) { - if (priv->extension) { - g_signal_handler_disconnect (priv->extension, - priv->extension_signal_id); - } - priv->extension_signal_id = 0; - } - g_clear_object (&priv->extension); - if (priv->attributes) { - GHashTable *attributes = priv->attributes; - - priv->attributes = NULL; - g_hash_table_unref (attributes); - } - - G_OBJECT_CLASS (maliit_settings_entry_parent_class)->dispose (object); -} - -static void -maliit_settings_entry_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) -{ - MaliitSettingsEntry *entry = MALIIT_SETTINGS_ENTRY (object); - MaliitSettingsEntryPrivate *priv = entry->priv; - - switch (prop_id) { - case PROP_EXTENSION: - if (priv->extension) { - g_object_unref (priv->extension); - } - priv->extension = g_value_dup_object (value); - break; - case PROP_DESCRIPTION: - g_free (priv->description); - priv->description = g_value_dup_string (value); - break; - case PROP_EXTENSION_KEY: - g_free (priv->extension_key); - priv->extension_key = g_value_dup_string (value); - break; - case PROP_TYPE: - priv->type = g_value_get_enum (value); - break; - case PROP_VALID: - priv->valid = g_value_get_boolean (value); - break; - case PROP_VALUE: - maliit_settings_entry_set_value (entry, g_value_get_variant (value)); - break; - case PROP_ATTRIBUTES: - if (priv->attributes) { - g_hash_table_unref (priv->attributes); - } - priv->attributes = g_value_dup_boxed (value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -maliit_settings_entry_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - MaliitSettingsEntry *entry = MALIIT_SETTINGS_ENTRY (object); - MaliitSettingsEntryPrivate *priv = entry->priv; - - switch (prop_id) { - /* PROP_EXTENSION is write only, construction only - omitted here */ - case PROP_DESCRIPTION: - g_value_set_string (value, priv->description); - break; - case PROP_EXTENSION_KEY: - g_value_set_string (value, priv->extension_key); - break; - case PROP_TYPE: - g_value_set_enum (value, priv->type); - break; - case PROP_VALID: - g_value_set_boolean (value, priv->valid); - break; - case PROP_VALUE: - g_value_set_variant (value, - maliit_settings_entry_get_value (entry)); - break; - case PROP_ATTRIBUTES: - g_value_set_boxed (value, priv->attributes); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -value_changed(MaliitSettingsEntry *entry, - const gchar *key, - GVariant *value G_GNUC_UNUSED, - gpointer user_data G_GNUC_UNUSED) -{ - if (!g_strcmp0 (key, entry->priv->extension_key)) { - g_signal_emit(entry, signals[VALUE_CHANGED], 0); - } -} - -static void -maliit_settings_entry_constructed (GObject *object) -{ - MaliitSettingsEntry *entry = MALIIT_SETTINGS_ENTRY (object); - MaliitSettingsEntryPrivate *priv = entry->priv; - - if (priv->extension) { - priv->extension_signal_id = g_signal_connect_swapped (priv->extension, - "extended-attribute-changed", - G_CALLBACK (value_changed), - entry); - } -} - -static void -maliit_settings_entry_class_init (MaliitSettingsEntryClass *entry_class) -{ - GObjectClass *g_object_class = G_OBJECT_CLASS (entry_class); - - g_object_class->finalize = maliit_settings_entry_finalize; - g_object_class->dispose = maliit_settings_entry_dispose; - g_object_class->set_property = maliit_settings_entry_set_property; - g_object_class->get_property = maliit_settings_entry_get_property; - g_object_class->constructed = maliit_settings_entry_constructed; - - /** - * MaliitSettingsEntry:extension: - * - * #MaliitAttributeExtension used by this entry. - */ - g_object_class_install_property (g_object_class, - PROP_EXTENSION, - g_param_spec_object ("extension", - "Extension", /* TODO: mark as translatable? */ - "Extension used by this entry", /* TODO: mark as translatable? */ - MALIIT_TYPE_ATTRIBUTE_EXTENSION, - G_PARAM_WRITABLE | - G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_NAME | - G_PARAM_STATIC_BLURB | - G_PARAM_STATIC_NICK)); - - /** - * MaliitSettingsEntry:description: - * - * Description of the entry. - */ - g_object_class_install_property (g_object_class, - PROP_DESCRIPTION, - g_param_spec_string ("description", - "Description", /* TODO: mark as translatable? */ - "Description of the entry", /* TODO: mark as translatable? */ - "", - G_PARAM_READABLE | - G_PARAM_WRITABLE | - G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_NAME | - G_PARAM_STATIC_BLURB | - G_PARAM_STATIC_NICK)); - - /** - * MaliitSettingsEntry:extension-key: - * - * Key of the entry. - */ - g_object_class_install_property (g_object_class, - PROP_EXTENSION_KEY, - g_param_spec_string ("extension-key", - "Extension key", /* TODO: mark as translatable? */ - "Key of the entry.", /* TODO: mark as translatable? */ - "", - G_PARAM_READABLE | - G_PARAM_WRITABLE | - G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_NAME | - G_PARAM_STATIC_BLURB | - G_PARAM_STATIC_NICK)); - - /** - * MaliitSettingsEntry:type: - * - * Type of the entry - */ - g_object_class_install_property (g_object_class, - PROP_TYPE, - g_param_spec_enum ("type", - "Type", /* TODO: mark as translatable? */ - "Type if the entry", /* TODO: mark as translatable? */ - MALIIT_TYPE_SETTINGS_ENTRY_TYPE, - MALIIT_STRING_TYPE, - G_PARAM_READABLE | - G_PARAM_WRITABLE | - G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_NAME | - G_PARAM_STATIC_BLURB | - G_PARAM_STATIC_NICK)); - - /** - * MaliitSettingsEntry:valid: - * - * Whether entry's value is valid. - */ - g_object_class_install_property (g_object_class, - PROP_VALID, - g_param_spec_boolean ("valid", - "Valid", /* TODO: mark as translatable? */ - "Whether entry's value is valid", /* TODO: mark as translatable? */ - FALSE, - G_PARAM_READABLE | - G_PARAM_WRITABLE | - G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_NAME | - G_PARAM_STATIC_BLURB | - G_PARAM_STATIC_NICK)); - - /** - * MaliitSettingsEntry:value: - * - * Value of the entry. - */ - g_object_class_install_property (g_object_class, - PROP_VALUE, - g_param_spec_variant ("value", - "Value", /* TODO: mark as translatable? */ - "Value of the entry", /* TODO: mark as translatable? */ - G_VARIANT_TYPE_ANY, - g_variant_new_int32 (0), - G_PARAM_READABLE | - G_PARAM_WRITABLE | - G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_NAME | - G_PARAM_STATIC_BLURB | - G_PARAM_STATIC_NICK)); - - /** - * MaliitSettingsEntry:attributes: - * - * Attributes of the entry. - */ - g_object_class_install_property (g_object_class, - PROP_ATTRIBUTES, - g_param_spec_boxed ("attributes", - "Attributes", /* TODO: mark as translatable? */ - "Attributes of the entry", /* TODO: mark as translatable? */ - G_TYPE_HASH_TABLE, - G_PARAM_READABLE | - G_PARAM_WRITABLE | - G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_NAME | - G_PARAM_STATIC_BLURB | - G_PARAM_STATIC_NICK)); - - /** - * MaliitSettingsEntry::value-changed: - * @entry: The #MaliitSettingsEntry emitting the signal. - * - * Emitted when value of the entry was changed in the plugin. - */ - signals[VALUE_CHANGED] = - g_signal_new ("value-changed", - MALIIT_TYPE_SETTINGS_ENTRY, - G_SIGNAL_RUN_FIRST, - 0, - NULL, - NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, - 0); -} - -static void -maliit_settings_entry_init (MaliitSettingsEntry *entry) -{ - MaliitSettingsEntryPrivate *priv = maliit_settings_entry_get_instance_private (entry); - - priv->extension = NULL; - priv->description = NULL; - priv->extension_key = NULL; - priv->type = MALIIT_STRING_TYPE; - priv->valid = FALSE; - priv->attributes = NULL; - priv->extension_signal_id = 0; - - entry->priv = priv; -} - -static GHashTable * -attributes_from_dbus_g_variant (GVariant *dbus_attributes) -{ - GHashTable *attributes = g_hash_table_new_full (g_str_hash, - g_str_equal, - g_free, - (GDestroyNotify)g_variant_unref); - GVariantIter iter; - gchar *key; - GVariant *value; - - g_variant_iter_init (&iter, dbus_attributes); - while (g_variant_iter_next (&iter, "{sv}", &key, &value)) { - g_hash_table_replace (attributes, key, value); - } - - return attributes; -} - -/** - * maliit_settings_entry_new_from_dbus_data: (skip) - * @info: (transfer none): A #GVariant of DBus provenance containing entry information. - * @extension: (transfer none): A #MaliitAttributeExtensions for #MaliitAttributeSettingsEntry instance. - * - * Creates new settings entry. This is used internally only by - * #MaliitPluginSettings. - * - * Returns: (transfer full): The newly created #MaliitSettingsEntry. - */ -MaliitSettingsEntry * -maliit_settings_entry_new_from_dbus_data (GVariant *info, - MaliitAttributeExtension *extension) -{ - const gchar *description; - const gchar *extension_key; - MaliitSettingsEntryType type; - gboolean valid; - GVariant *value; - GVariant *attrs; - GHashTable *attributes; - MaliitSettingsEntry *entry; - - g_return_val_if_fail (MALIIT_IS_ATTRIBUTE_EXTENSION (extension), NULL); - - g_variant_get (info, "(&s&sib@v@a{sv})", &description, &extension_key, &type, &valid, &value, &attrs); - - attributes = attributes_from_dbus_g_variant (attrs); - entry = MALIIT_SETTINGS_ENTRY (g_object_new (MALIIT_TYPE_SETTINGS_ENTRY, - "extension", extension, - "description", description, - "extension-key", extension_key, - "type", type, - "valid", valid, - "value", value, - "attributes", attributes, - NULL)); - - g_hash_table_unref (attributes); - g_variant_unref (attrs); - g_variant_unref (value); - return entry; -} - -/** - * maliit_settings_entry_get_description: - * @entry: (transfer none): The #MaliitSettingsEntry. - * - * Gets description of the entry. - * - * Returns: (transfer none): A description. Returned value should not be modified nor freed. - */ -const gchar * -maliit_settings_entry_get_description (MaliitSettingsEntry *entry) -{ - g_return_val_if_fail (MALIIT_IS_SETTINGS_ENTRY (entry), NULL); - - return entry->priv->description; -} - -/** - * maliit_settings_entry_get_key: - * @entry: (transfer none): The #MaliitSettingsEntry. - * - * Gets key of the entry. - * - * Returns: (transfer none): A key. Returned value should not be modified nor freed. - */ -const gchar * -maliit_settings_entry_get_key (MaliitSettingsEntry *entry) -{ - g_return_val_if_fail (MALIIT_IS_SETTINGS_ENTRY (entry), NULL); - - return entry->priv->extension_key; -} - -/** - * maliit_settings_entry_get_entry_type: - * @entry: (transfer none): The #MaliitSettingsEntry. - * - * Gets type of the entry. - * - * Returns: A type. - */ -MaliitSettingsEntryType -maliit_settings_entry_get_entry_type (MaliitSettingsEntry *entry) -{ - g_return_val_if_fail (MALIIT_IS_SETTINGS_ENTRY (entry), MALIIT_STRING_TYPE); - - return entry->priv->type; -} - -/** - * maliit_settings_entry_is_current_value_valid: - * @entry: (transfer none): The #MaliitSettingsEntry. - * - * Gets whether current value of the entry is valid. - * - * Returns: %TRUE if valid, otherwise %FALSE - */ -gboolean -maliit_settings_entry_is_current_value_valid (MaliitSettingsEntry *entry) -{ - g_return_val_if_fail (MALIIT_IS_SETTINGS_ENTRY (entry), FALSE); - - return entry->priv->valid; -} - -/** - * maliit_settings_entry_get_value: - * @entry: (transfer none): The #MaliitSettingsEntry. - * - * Gets value of the entry. Check its validity with - * maliit_settings_entry_is_current_value_valid() before using it. - * - * Returns: (transfer none): A value. - */ -GVariant * -maliit_settings_entry_get_value (MaliitSettingsEntry *entry) -{ - GHashTable *attributes; - MaliitSettingsEntryPrivate *priv; - - g_return_val_if_fail (MALIIT_IS_SETTINGS_ENTRY (entry), NULL); - - priv = entry->priv; - attributes = maliit_attribute_extension_get_attributes (priv->extension); - - return g_hash_table_lookup (attributes, priv->extension_key); -} - -/** - * maliit_settings_entry_set_value: - * @entry: (transfer none): The #MaliitSettingsEntry. - * @value: (transfer none): The #GVariant. - * - * Sets a new value of the entry. Before setting new value, validate - * it with maliit_settings_entry_is_value_valid(). - */ -void -maliit_settings_entry_set_value (MaliitSettingsEntry *entry, - GVariant *value) -{ - MaliitSettingsEntryPrivate *priv; - - g_return_if_fail (MALIIT_IS_SETTINGS_ENTRY (entry)); - - priv = entry->priv; - maliit_attribute_extension_set_attribute (priv->extension, - priv->extension_key, - value); -} - -/** - * maliit_settings_entry_is_value_valid: - * @entry: (transfer none): The #MaliitSettingsEntry. - * @value: (transfer none): The #GVariant - * - * Checks whether the value is valid one for the entry. - * - * Returns: %TRUE if valid, otherwise %FALSE. - */ -gboolean -maliit_settings_entry_is_value_valid (MaliitSettingsEntry *entry, - GVariant *value) -{ - MaliitSettingsEntryPrivate *priv; - - g_return_val_if_fail (MALIIT_IS_SETTINGS_ENTRY (entry), FALSE); - - priv = entry->priv; - return maliit_validate_setting_value (priv->type, priv->attributes, value); -} - -/** - * maliit_settings_entry_get_attributes: - * @entry: (transfer none): The #MaliitSettingsEntry. - * - * Gets attributes of the entry. The keys of the attributes are - * MALIIT_SETTING_VALUE_DOMAIN(), - * MALIIT_SETTING_VALUE_DOMAIN_DESCRIPTIONS(), - * MALIIT_SETTING_VALUE_RANGE_MIN(), MALIIT_SETTING_VALUE_RANGE_MAX() - * and MALIIT_SETTING_DEFAULT_VALUE(). Note that these keys don't have - * to exist in attributes. - * - * Returns: (transfer none) (element-type utf8 GLib.Variant): Attributes. Returned value should not be modified nor freed. - */ -GHashTable * -maliit_settings_entry_get_attributes (MaliitSettingsEntry *entry) -{ - g_return_val_if_fail (MALIIT_IS_SETTINGS_ENTRY (entry), NULL); - - return entry->priv->attributes; -} diff --git a/maliit-glib/maliitsettingsentry.h b/maliit-glib/maliitsettingsentry.h deleted file mode 100644 index b145da07..00000000 --- a/maliit-glib/maliitsettingsentry.h +++ /dev/null @@ -1,91 +0,0 @@ -/* This file is part of Maliit framework - * - * Copyright (C) 2012 Canonical Ltd - * - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the licence, or (at your option) any later version. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef MALIIT_GLIB_SETTINGS_ENTRY_H -#define MALIIT_GLIB_SETTINGS_ENTRY_H - -#include -#include - -#include "maliitsettingdata.h" - -G_BEGIN_DECLS - -#define MALIIT_TYPE_SETTINGS_ENTRY (maliit_settings_entry_get_type()) -#define MALIIT_SETTINGS_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_CAST(obj, MALIIT_TYPE_SETTINGS_ENTRY, MaliitSettingsEntry)) -#define MALIIT_SETTINGS_ENTRY_CLASS(cls) (G_TYPE_CHECK_CLASS_CAST(cls, MALIIT_TYPE_SETTINGS_ENTRY, MaliitSettingsEntryClass)) -#define MALIIT_IS_SETTINGS_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_TYPE(obj, MALIIT_TYPE_SETTINGS_ENTRY)) -#define MALIIT_IS_SETTINGS_ENTRY_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE(obj, MALIIT_TYPE_SETTINGS_ENTRY)) -#define MALIIT_SETTINGS_ENTRY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), MALIIT_TYPE_SETTINGS_ENTRY, MaliitSettingsEntryClass)) - -typedef struct _MaliitSettingsEntry MaliitSettingsEntry; -typedef struct _MaliitSettingsEntryClass MaliitSettingsEntryClass; -typedef struct _MaliitSettingsEntryPrivate MaliitSettingsEntryPrivate; - -struct _MaliitSettingsEntry -{ - GObject parent; - - /*< private >*/ - MaliitSettingsEntryPrivate *priv; -}; - -/** - * MaliitSettingsEntryClass: - * @parent_class: The parent class. - */ -struct _MaliitSettingsEntryClass -{ - GObjectClass parent_class; -}; - -GType -maliit_settings_entry_get_type (void) G_GNUC_CONST; - -const gchar * -maliit_settings_entry_get_description (MaliitSettingsEntry *entry); - -const gchar * -maliit_settings_entry_get_key (MaliitSettingsEntry *entry); - -MaliitSettingsEntryType -maliit_settings_entry_get_entry_type (MaliitSettingsEntry *entry); - -gboolean -maliit_settings_entry_is_current_value_valid (MaliitSettingsEntry *entry); - -GVariant * -maliit_settings_entry_get_value (MaliitSettingsEntry *entry); - -void -maliit_settings_entry_set_value (MaliitSettingsEntry *entry, - GVariant *value); - -gboolean -maliit_settings_entry_is_value_valid (MaliitSettingsEntry *entry, - GVariant *value); - -GHashTable * -maliit_settings_entry_get_attributes (MaliitSettingsEntry *entry); - -G_END_DECLS - -#endif /* MALIIT_GLIB_SETTINGS_ENTRY_H */ diff --git a/maliit-glib/maliitsettingsentryprivate.h b/maliit-glib/maliitsettingsentryprivate.h deleted file mode 100644 index c2417747..00000000 --- a/maliit-glib/maliitsettingsentryprivate.h +++ /dev/null @@ -1,36 +0,0 @@ -/* This file is part of Maliit framework - * - * Copyright (C) 2012 Canonical Ltd - * - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the licence, or (at your option) any later version. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef MALIIT_GLIB_SETTINGS_ENTRY_PRIVATE_H -#define MALIIT_GLIB_SETTINGS_ENTRY_PRIVATE_H - -#include "maliitattributeextension.h" -#include "maliitsettingsentry.h" - -G_BEGIN_DECLS - -MaliitSettingsEntry * -maliit_settings_entry_new_from_dbus_data (GVariant *info, - MaliitAttributeExtension *extension); - -G_END_DECLS - -#endif /* MALIIT_GLIB_SETTINGS_ENTRY_PRIVATE_H */ diff --git a/maliit-glib/maliitsettingsmanager.c b/maliit-glib/maliitsettingsmanager.c deleted file mode 100644 index 355be7bf..00000000 --- a/maliit-glib/maliitsettingsmanager.c +++ /dev/null @@ -1,352 +0,0 @@ -/* This file is part of Maliit framework - * - * Copyright (C) 2012 Canonical Ltd - * - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the licence, or (at your option) any later version. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include "maliitsettingsmanager.h" -#include "maliitpluginsettingsprivate.h" -#include "maliitattributeextensionprivate.h" -#include "maliitbus.h" - -/** - * SECTION:maliitsettingsmanager - * @short_description: settings manager - * @title: MaliitSettingsManager - * @see_also: #MaliitSettingsEntry, #MaliitPluginSettings - * @stability: Stable - * @include: maliit/maliitsettingsmanager.h - * - * The #MaliitSettingsManager handles requesting and receiving plugin - * settings from maliit-server and notifying when those settings has - * changed. - */ - -static gchar* preferred_description_locale = 0; - -struct _MaliitSettingsManagerPrivate -{ - MaliitAttributeExtension *settings_list_changed; - guint attribute_changed_signal_id; -}; - -G_DEFINE_TYPE_WITH_CODE (MaliitSettingsManager, maliit_settings_manager, - G_TYPE_OBJECT, G_ADD_PRIVATE (MaliitSettingsManager)) - -enum -{ - PLUGIN_SETTINGS_RECEIVED, - CONNECTED, - DISCONNECTED, - - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = { 0 }; - -static void -maliit_settings_manager_finalize (GObject *object) -{ - G_OBJECT_CLASS (maliit_settings_manager_parent_class)->finalize (object); -} - -static void -maliit_settings_manager_dispose (GObject *object) -{ - GError *error = NULL; - MaliitSettingsManager *manager = MALIIT_SETTINGS_MANAGER (object); - MaliitContext *context = maliit_get_context_sync (NULL, &error); - - if (context) { - g_signal_handlers_disconnect_by_data (context, manager); - } else { - g_warning ("Unable to connect to context: %s", error->message); - g_clear_error (&error); - } - - if (manager->priv->settings_list_changed) { - g_signal_handlers_disconnect_by_data (manager->priv->settings_list_changed, manager); - } - - g_clear_object (&manager->priv->settings_list_changed); - - G_OBJECT_CLASS (maliit_settings_manager_parent_class)->dispose (object); -} - -static void -maliit_settings_manager_class_init (MaliitSettingsManagerClass *manager_class) -{ - GObjectClass *g_object_class = G_OBJECT_CLASS (manager_class); - - g_object_class->finalize = maliit_settings_manager_finalize; - g_object_class->dispose = maliit_settings_manager_dispose; - - /** - * MaliitSettingsManager::plugin-settings-received: - * @manager: The #MaliitSettingsManager emitting the signal. - * @settings: (type GLib.List) (element-type Maliit.PluginSettings): Gotten settings. - * - * Emitted after call to - * maliit_settings_manager_load_plugin_settings() and when the - * plugin list changes on the server. - */ - signals[PLUGIN_SETTINGS_RECEIVED] = - g_signal_new ("plugin-settings-received", - MALIIT_TYPE_SETTINGS_MANAGER, - G_SIGNAL_RUN_FIRST, - 0, - NULL, - NULL, - g_cclosure_marshal_VOID__POINTER, - G_TYPE_NONE, - 1, - G_TYPE_POINTER); - - /** - * MaliitSettingsManager::connected: - * @manager: The #MaliitSettingsManager emitting the signal. - * - * Emitted when connection to maliit-server is established. - */ - signals[CONNECTED] = - g_signal_new ("connected", - MALIIT_TYPE_SETTINGS_MANAGER, - G_SIGNAL_RUN_FIRST, - 0, - NULL, - NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, - 0); - - /** - * MaliitSettingsManager::disconnected: - * @manager: The #MaliitSettingsManager emitting the signal. - * - * Emitted when connection to maliit-server is broken. - * - * Deprecated: 0.99.0: This signal will no longer be emitted. - */ - signals[DISCONNECTED] = - g_signal_new ("disconnected", - MALIIT_TYPE_SETTINGS_MANAGER, - G_SIGNAL_RUN_FIRST, - 0, - NULL, - NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, - 0); -} - -static void -on_connection_established (MaliitSettingsManager *manager, - gpointer user_data G_GNUC_UNUSED) -{ - g_signal_emit(manager, signals[CONNECTED], 0); -} - -static gboolean -on_plugins_loaded (MaliitSettingsManager *manager, - GDBusMethodInvocation *invocation G_GNUC_UNUSED, - GVariant *plugin_settings, - gpointer user_data G_GNUC_UNUSED) -{ - guint iter; - GList *result; - GHashTable *extensions; - GVariant *plugin_info; - - if (!plugin_settings) { - return FALSE; - } - - result = NULL; - extensions = g_hash_table_new (g_direct_hash, - g_direct_equal); - - for (iter = 0; iter < g_variant_n_children (plugin_settings); ++iter) { - const gchar *plugin_name; - int extension_id; - - g_variant_get_child (plugin_settings, iter, "(&s&s&si@a(ssibva{sv}))", NULL, &plugin_name, NULL, &extension_id, NULL); - - if (!g_strcmp0(plugin_name, "@settings")) { - MaliitSettingsManagerPrivate *priv = manager->priv; - - if (priv->attribute_changed_signal_id) { - if (priv->settings_list_changed) { - g_signal_handler_disconnect (priv->settings_list_changed, - priv->attribute_changed_signal_id); - g_clear_object (&priv->settings_list_changed); - } - priv->attribute_changed_signal_id = 0; - } - - priv->settings_list_changed = maliit_attribute_extension_new_with_id (extension_id); - priv->attribute_changed_signal_id = g_signal_connect_swapped (priv->settings_list_changed, - "extended-attribute-changed", - G_CALLBACK (maliit_settings_manager_load_plugin_settings), - manager); - } else { - MaliitAttributeExtension *extension = g_hash_table_lookup (extensions, - GINT_TO_POINTER (extension_id)); - - if (!extension) { - extension = maliit_attribute_extension_new_with_id (extension_id); - g_hash_table_insert (extensions, GINT_TO_POINTER (extension_id), extension); - } - - plugin_info = g_variant_get_child_value (plugin_settings, iter); - - result = g_list_prepend (result, - maliit_plugin_settings_new_from_dbus_data (plugin_info, - extension)); - - g_variant_unref (plugin_info); - } - } - - result = g_list_reverse (result); - g_signal_emit (manager, - signals[PLUGIN_SETTINGS_RECEIVED], - 0, - result); - - g_list_free_full (result, - g_object_unref); - - return FALSE; -} - -static void -connection_established (GObject *source_object G_GNUC_UNUSED, - GAsyncResult *res, - gpointer user_data) -{ - GError *error = NULL; - MaliitServer *server = maliit_get_server_finish (res, &error); - - if (server) { - on_connection_established (user_data, server); - } else { - g_warning ("Unable to connect to server: %s", error->message); - g_clear_error (&error); - } -} - -static void -maliit_settings_manager_init (MaliitSettingsManager *manager) -{ - MaliitSettingsManagerPrivate *priv = maliit_settings_manager_get_instance_private (manager); - MaliitContext *context; - GError *error = NULL; - - priv->settings_list_changed = NULL; - priv->attribute_changed_signal_id = 0; - manager->priv = priv; - - maliit_get_server (NULL, connection_established, manager); - - context = maliit_get_context_sync (NULL, &error); - - if (context) { - g_signal_connect_swapped (context, - "handle-plugin-settings-loaded", - G_CALLBACK (on_plugins_loaded), - manager); - } else { - g_warning ("Unable to connect to context: %s", error->message); - g_clear_error (&error); - } -} - -/** - * maliit_settings_manager_new: - * - * Creates new settings manager. - * - * Returns: (transfer full): The newly created - * #MaliitSettingsManager. - */ -MaliitSettingsManager * -maliit_settings_manager_new (void) -{ - return MALIIT_SETTINGS_MANAGER (g_object_new (MALIIT_TYPE_SETTINGS_MANAGER, - NULL)); -} - -/** - * maliit_settings_manager_load_plugin_settings: - * @manager: (transfer none): The #MaliitSettingsManager. - * - * Request the list of settings from maliit-server. - * The settings will be returned async via the MaliitServerManager::plugin-settings-received signal - */ -void -maliit_settings_manager_load_plugin_settings (MaliitSettingsManager *manager) -{ - MaliitServer *server; - GError *error = NULL; - - g_return_if_fail (MALIIT_IS_SETTINGS_MANAGER (manager)); - - server = maliit_get_server_sync (NULL, &error); - - if (!server) { - g_warning ("Unable to connect to server: %s", error->message); - g_clear_error (&error); - } -} - -/** - * maliit_settings_manager_set_preferred_description_locale: - * @locale_name: (transfer none): The new preferred locale. - * - * Sets the preferred locale for human-readable descriptions. The setting is - * valid for all instances of #MaliitSettingsManager in the process. - * Note that the server may not always be able to return info in the requested locale. - */ -void -maliit_settings_manager_set_preferred_description_locale (const gchar *locale_name) -{ - g_return_if_fail (locale_name != NULL); - - if (preferred_description_locale) { - g_free (preferred_description_locale); - } - preferred_description_locale = g_strdup (locale_name); -} - -/** - * maliit_settings_manager_get_preferred_description_locale: - * - * Gets the preferred locale for human-readable description. - * - * Returns: (transfer none): The string being a current preferred - * locale. Returned string should not be freed nor modified. - */ -const gchar * -maliit_settings_manager_get_preferred_description_locale (void) -{ - if (!preferred_description_locale) { - preferred_description_locale = g_strdup("en"); - } - - return preferred_description_locale; -} diff --git a/maliit-glib/maliitsettingsmanager.h b/maliit-glib/maliitsettingsmanager.h deleted file mode 100644 index 20533c8a..00000000 --- a/maliit-glib/maliitsettingsmanager.h +++ /dev/null @@ -1,75 +0,0 @@ -/* This file is part of Maliit framework - * - * Copyright (C) 2012 Canonical Ltd - * - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the licence, or (at your option) any later version. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef MALIIT_GLIB_SETTINGS_MANAGER_H -#define MALIIT_GLIB_SETTINGS_MANAGER_H - -#include -#include - -G_BEGIN_DECLS - -#define MALIIT_TYPE_SETTINGS_MANAGER (maliit_settings_manager_get_type()) -#define MALIIT_SETTINGS_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST(obj, MALIIT_TYPE_SETTINGS_MANAGER, MaliitSettingsManager)) -#define MALIIT_SETTINGS_MANAGER_CLASS(cls) (G_TYPE_CHECK_CLASS_CAST(cls, MALIIT_TYPE_SETTINGS_MANAGER, MaliitSettingsManagerClass)) -#define MALIIT_IS_SETTINGS_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE(obj, MALIIT_TYPE_SETTINGS_MANAGER)) -#define MALIIT_IS_SETTINGS_MANAGER_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE(obj, MALIIT_TYPE_SETTINGS_MANAGER)) -#define MALIIT_SETTINGS_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), MALIIT_TYPE_SETTINGS_MANAGER, MaliitSettingsManagerClass)) - -typedef struct _MaliitSettingsManager MaliitSettingsManager; -typedef struct _MaliitSettingsManagerClass MaliitSettingsManagerClass; -typedef struct _MaliitSettingsManagerPrivate MaliitSettingsManagerPrivate; - -struct _MaliitSettingsManager -{ - GObject parent; - - /*< private >*/ - MaliitSettingsManagerPrivate *priv; -}; - -/** - * MaliitSettingsManagerClass: - * @parent_class: The parent class. - */ -struct _MaliitSettingsManagerClass -{ - GObjectClass parent_class; -}; - -GType -maliit_settings_manager_get_type (void) G_GNUC_CONST; - -MaliitSettingsManager * -maliit_settings_manager_new (void); - -void -maliit_settings_manager_load_plugin_settings (MaliitSettingsManager *manager); - -void -maliit_settings_manager_set_preferred_description_locale (const gchar *locale_name); - -const gchar * -maliit_settings_manager_get_preferred_description_locale (void); - -G_END_DECLS - -#endif /* MALIIT_GLIB_SETTINGS_MANAGER_H */ diff --git a/tests/ut_maliit_glib_settings/.gitignore b/tests/ut_maliit_glib_settings/.gitignore deleted file mode 100644 index 8be46e8d..00000000 --- a/tests/ut_maliit_glib_settings/.gitignore +++ /dev/null @@ -1 +0,0 @@ -ut_maliit_glib_settings diff --git a/tests/ut_maliit_glib_settings/mockmaliitserver.c b/tests/ut_maliit_glib_settings/mockmaliitserver.c deleted file mode 100644 index ed4d7d19..00000000 --- a/tests/ut_maliit_glib_settings/mockmaliitserver.c +++ /dev/null @@ -1,164 +0,0 @@ -/* This file is part of Maliit framework - * - * Copyright (C) 2012 Canonical Ltd - * - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the licence, or (at your option) any later version. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include "mockmaliitserver.h" - -#include -#include -#include -#include -#include - -#define SERVER_OBJECT_PATH "/com/meego/inputmethod/uiserver1" -#define CONTEXT_OBJECT_PATH "/com/meego/inputmethod/inputcontext" - -struct _MockMaliitServerPriv { - GDBusConnection *server_connection; - GDBusConnection *client_connection; - - MaliitServer *server; - MaliitContext *context; - - GThread *thread; - GMainContext *thread_context; - GMainLoop *thread_loop; - GCond thread_cond; - GMutex thread_mutex; -}; - -static gboolean -start_server(gpointer user_data) -{ - MockMaliitServer *self = user_data; - - g_main_context_push_thread_default(self->priv->thread_context); - - g_mutex_lock(&self->priv->thread_mutex); - - self->priv->server = maliit_server_skeleton_new(); - g_assert_true(g_dbus_interface_skeleton_export(G_DBUS_INTERFACE_SKELETON(self->priv->server), - self->priv->server_connection, - SERVER_OBJECT_PATH, - NULL)); - - g_cond_signal(&self->priv->thread_cond); - g_mutex_unlock(&self->priv->thread_mutex); - - g_main_context_pop_thread_default(self->priv->thread_context); - - return G_SOURCE_REMOVE; -} - -static gpointer -run_server_thread(gpointer data) -{ - MockMaliitServer *self = data; - - g_main_context_push_thread_default(self->priv->thread_context); - - g_main_context_invoke(self->priv->thread_context, start_server, self); - - self->priv->thread_loop = g_main_loop_new(self->priv->thread_context, FALSE); - g_main_loop_run(self->priv->thread_loop); - g_main_loop_unref(self->priv->thread_loop); - self->priv->thread_loop = NULL; - - g_main_context_pop_thread_default(self->priv->thread_context); - - return NULL; -} - -MockMaliitServer * -mock_maliit_server_new() -{ - MockMaliitServer *self = g_new0(MockMaliitServer, 1); - int server_to_client[2] = { 0 }; - int client_to_server[2] = { 0 }; - GInputStream *server_input_stream; - GOutputStream *server_output_stream; - GIOStream *server_stream; - GInputStream *client_input_stream; - GOutputStream *client_output_stream; - GIOStream *client_stream; - - self->priv = g_new0(MockMaliitServerPriv, 1); - - g_assert_true(pipe(server_to_client) == 0); - g_assert_true(pipe(client_to_server) == 0); - - server_input_stream = g_unix_input_stream_new(client_to_server[0], TRUE); - server_output_stream = g_unix_output_stream_new(server_to_client[1], TRUE); - server_stream = g_simple_io_stream_new(server_input_stream, server_output_stream); - g_object_unref(server_output_stream); - g_object_unref(server_input_stream); - self->priv->server_connection = g_dbus_connection_new_sync(server_stream, - NULL, - G_DBUS_CONNECTION_FLAGS_NONE, - NULL, - NULL, - NULL); - g_object_unref(server_stream); - g_assert_nonnull(self->priv->server_connection); - - client_input_stream = g_unix_input_stream_new(server_to_client[0], TRUE); - client_output_stream = g_unix_output_stream_new(client_to_server[1], TRUE); - client_stream = g_simple_io_stream_new(client_input_stream, client_output_stream); - g_object_unref(client_output_stream); - g_object_unref(client_input_stream); - self->priv->client_connection = g_dbus_connection_new_sync(client_stream, - NULL, - G_DBUS_CONNECTION_FLAGS_NONE, - NULL, - NULL, - NULL); - g_object_unref(client_stream); - g_assert_nonnull(self->priv->client_connection); - - self->priv->thread_context = g_main_context_new(); - self->priv->thread = g_thread_new(NULL, run_server_thread, self); - - g_mutex_lock(&self->priv->thread_mutex); - - while (!self->priv->server) { - g_cond_wait(&self->priv->thread_cond, &self->priv->thread_mutex); - } - - g_mutex_unlock(&self->priv->thread_mutex); - - return self; -} - -void -mock_maliit_server_free(MockMaliitServer *self) -{ - g_clear_object(&self->priv->context); - g_clear_object(&self->priv->server); - g_clear_object(&self->priv->client_connection); - g_clear_object(&self->priv->server_connection); - g_free(self->priv); - g_free(self); -} - -GDBusConnection * -mock_maliit_server_get_bus(MockMaliitServer *self) -{ - return self->priv->client_connection; -} diff --git a/tests/ut_maliit_glib_settings/mockmaliitserver.h b/tests/ut_maliit_glib_settings/mockmaliitserver.h deleted file mode 100644 index eaaa614c..00000000 --- a/tests/ut_maliit_glib_settings/mockmaliitserver.h +++ /dev/null @@ -1,40 +0,0 @@ -/* This file is part of Maliit framework - * - * Copyright (C) 2012 Canonical Ltd - * - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the licence, or (at your option) any later version. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef MOCKMALIITSERVER_H -#define MOCKMALIITSERVER_H - -#include -#include - -typedef struct _MockMaliitServerPriv MockMaliitServerPriv; - -typedef struct { - MockMaliitServerPriv *priv; - GVariant *settings; /* To be set by tests */ -} MockMaliitServer; - -MockMaliitServer *mock_maliit_server_new(); -void mock_maliit_server_free(MockMaliitServer *self); - -GDBusConnection *mock_maliit_server_get_bus(MockMaliitServer *server); - -#endif // MOCKMALIITSERVER_H diff --git a/tests/ut_maliit_glib_settings/ut_maliit_glib_settings.c b/tests/ut_maliit_glib_settings/ut_maliit_glib_settings.c deleted file mode 100644 index 07069c5d..00000000 --- a/tests/ut_maliit_glib_settings/ut_maliit_glib_settings.c +++ /dev/null @@ -1,115 +0,0 @@ -/* This file is part of Maliit framework - * - * Copyright (C) 2012 Canonical Ltd - * - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the licence, or (at your option) any later version. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ -#include -#include - -#include "../../maliit-glib/maliitbusprivate.h" - -#include "mockmaliitserver.h" - -/** - * ut_maliit_glib_settings: Unit tests for the settings API of maliit-glib - * - * Testing is done using the public API of maliit-glib. - * maliit-server is mocked out due to the difficulties of hosting it in - * the tests and connecting the client to it (pulls in DBus session). - * - * --------------- ------------------ - * | maliit-glib | | MOCK | - * | settings | Connection API | maliit-server | - * | component | <----------> | | - * --------------- ------------------ - */ - -/* - * TODO: - * - * - Test that maliit_settings_entry_is_value_valid returns FALSE for incorrect values, - * and TRUE for correct values; for all of the different setting types. - * Simply need to enumerate a set of data and expected result - * Each data pair should be registered as a separate test - * This can be done with g_test_add_data_func - * - * - Test that the plugin settings are received correctly, - * and that the MaliitSettingsEntry APIs give access to the data. - * Can be done the same way as test_load_plugins_settings_returns_settings, - * but populating the MockMaliitServer::settings with DBus data. - * Verify result through: - * maliit_settings_entry_get_description - * maliit_settings_entry_get_key - * maliit_settings_entry_get_entry_type - * maliit_settings_entry_get_value - * maliit_settings_entry_get_attributes - * maliit_settings_entry_is_current_value_valid - * - * - Test that maliit_settings_manager_set_preferred_description_locale() - * results in the server replying with descriptions in that locale. - * Can be done by passing fake Bus settings data, including descriptions - * and implementing in MockMaliitServer a translation mechanism that respects - * the preferred locale. - * - * - Test that setting a value using maliit_settings_entry_set_value - * results in the server being called with the updated value. - * Can be done by observing meego_im_proxy_set_extended_attribute - * (wrap this implementation detail in MockMaliitServer) - * - * - Test that when a setting entry is updated on server side, - * the client is notified through MaliitSettingsEntry::value-changed. - * Can be done by emulating the meego_imcontext_notify_extended_attribute_changed - * from maliit-server (add to MockMaliitServer) - */ - -/** - * Test that #MaliitSettingsManager has a default for preferred_description_locale - */ -void -test_preferred_description_locale_default(void) -{ - const gchar *preferred_description_locale = maliit_settings_manager_get_preferred_description_locale(); - g_assert_cmpstr(preferred_description_locale, ==, "en"); -} - -/** - * Test that #MaliitSettingsManager has a default for preferred_description_locale - */ -void -test_preferred_description_locale_set_get_roundtrip(void) -{ - const char *expected = "no_NB"; - maliit_settings_manager_set_preferred_description_locale(expected); - const gchar *actual = maliit_settings_manager_get_preferred_description_locale(); - g_assert_cmpstr(actual, ==, expected); -} - -int -main (int argc, char **argv) { - g_test_init(&argc, &argv, NULL); -#if !(GLIB_CHECK_VERSION(2, 35, 0)) - g_type_init(); -#endif - - g_test_add_func("/ut_maliit_glib_settings/MaliitSettingsManager/preferred_description_locale/default", - test_preferred_description_locale_default); - g_test_add_func("/ut_maliit_glib_settings/MaliitSettingsManager/preferred_description_locale/set-get-roundtrip", - test_preferred_description_locale_set_get_roundtrip); - - return g_test_run(); -} From 248c2deea821fd56186e9179357f597e34ca59c6 Mon Sep 17 00:00:00 2001 From: Rodney Dawes Date: Tue, 14 Jun 2022 16:56:50 -0400 Subject: [PATCH 09/13] glib: Remove AttributeExtension API from maliit-glib --- CMakeLists.txt | 5 - maliit-glib/maliit-docs.xml | 1 - maliit-glib/maliit-sections.txt | 55 --- maliit-glib/maliitattributeextension.c | 457 ------------------ maliit-glib/maliitattributeextension.h | 96 ---- maliit-glib/maliitattributeextensionprivate.h | 31 -- .../maliitattributeextensionregistry.c | 343 ------------- .../maliitattributeextensionregistry.h | 93 ---- 8 files changed, 1081 deletions(-) delete mode 100644 maliit-glib/maliitattributeextension.c delete mode 100644 maliit-glib/maliitattributeextension.h delete mode 100644 maliit-glib/maliitattributeextensionprivate.h delete mode 100644 maliit-glib/maliitattributeextensionregistry.c delete mode 100644 maliit-glib/maliitattributeextensionregistry.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 2cbb47be..ba35dc58 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -212,11 +212,6 @@ if(enable-glib) find_package(GIO) set(GLIB_SOURCES - maliit-glib/maliitattributeextension.c - maliit-glib/maliitattributeextension.h - maliit-glib/maliitattributeextensionprivate.h - maliit-glib/maliitattributeextensionregistry.c - maliit-glib/maliitattributeextensionregistry.h maliit-glib/maliitbus.c maliit-glib/maliitbus.h maliit-glib/maliitbusprivate.h diff --git a/maliit-glib/maliit-docs.xml b/maliit-glib/maliit-docs.xml index 37b9d60a..8672e941 100644 --- a/maliit-glib/maliit-docs.xml +++ b/maliit-glib/maliit-docs.xml @@ -16,7 +16,6 @@ Maliit - diff --git a/maliit-glib/maliit-sections.txt b/maliit-glib/maliit-sections.txt index 42599c26..e2f8c1e9 100644 --- a/maliit-glib/maliit-sections.txt +++ b/maliit-glib/maliit-sections.txt @@ -1,58 +1,3 @@ -
-maliitattributeextension -MaliitAttributeExtension -MaliitAttributeExtension -MaliitAttributeExtensionClass -maliit_attribute_extension_attach_to_object -maliit_attribute_extension_get_attributes -maliit_attribute_extension_get_filename -maliit_attribute_extension_get_id -maliit_attribute_extension_new -maliit_attribute_extension_new_with_filename -maliit_attribute_extension_set_attribute -maliit_attribute_extension_update_attribute - -MALIIT_ATTRIBUTE_EXTENSION -MALIIT_ATTRIBUTE_EXTENSION_CLASS -MALIIT_ATTRIBUTE_EXTENSION_GET_CLASS -MALIIT_IS_ATTRIBUTE_EXTENSION -MALIIT_IS_ATTRIBUTE_EXTENSION_CLASS -MALIIT_TYPE_ATTRIBUTE_EXTENSION -MaliitAttributeExtensionPrivate -maliit_attribute_extension_get_type -
- -
- -maliitattributeextensionprivate -MALIIT_ATTRIBUTE_EXTENSION_DATA -MALIIT_ATTRIBUTE_EXTENSION_DATA_QUARK -maliit_attribute_extension_new_with_id -
- -
- -maliitattributeextensionregistry -MaliitAttributeExtensionRegistry -MaliitAttributeExtensionRegistry -MaliitAttributeExtensionRegistryClass -maliit_attribute_extension_registry_add_extension -maliit_attribute_extension_registry_extension_changed -maliit_attribute_extension_registry_get_extensions -maliit_attribute_extension_registry_get_instance -maliit_attribute_extension_registry_remove_extension -maliit_attribute_extension_registry_update_attribute - -MALIIT_ATTRIBUTE_EXTENSION_REGISTRY -MALIIT_ATTRIBUTE_EXTENSION_REGISTRY_CLASS -MALIIT_ATTRIBUTE_EXTENSION_REGISTRY_GET_CLASS -MALIIT_IS_ATTRIBUTE_EXTENSION_REGISTRY -MALIIT_IS_ATTRIBUTE_EXTENSION_REGISTRY_CLASS -MALIIT_TYPE_ATTRIBUTE_EXTENSION_REGISTRY -MaliitAttributeExtensionRegistryPrivate -maliit_attribute_extension_registry_get_type -
-
maliitinputmethod MaliitInputMethod diff --git a/maliit-glib/maliitattributeextension.c b/maliit-glib/maliitattributeextension.c deleted file mode 100644 index 72c90a0f..00000000 --- a/maliit-glib/maliitattributeextension.c +++ /dev/null @@ -1,457 +0,0 @@ -/* This file is part of Maliit framework - * - * Copyright (C) 2012 One Laptop per Child Association - * - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the licence, or (at your option) any later version. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include "maliitattributeextension.h" -#include "maliitattributeextensionprivate.h" -#include "maliitattributeextensionregistry.h" -#include "maliitmarshallers.h" - -/** - * SECTION:maliitattributeextension - * @short_description: attribute extensions - * @title: MaliitAttributeExtension - * @stability: Stable - * @include: maliit/maliitattributeextension.h - * - * #MaliitAttributeExtension class can be used by application to - * override some aspect of IM plugin currently used, like the looks of - * action key. - */ - -struct _MaliitAttributeExtensionPrivate -{ - int id; - gchar *filename; - GHashTable *attributes; - MaliitAttributeExtensionRegistry *registry; -}; - -G_DEFINE_TYPE_WITH_CODE (MaliitAttributeExtension, maliit_attribute_extension, - G_TYPE_OBJECT, G_ADD_PRIVATE (MaliitAttributeExtension)) - -enum -{ - EXTENDED_ATTRIBUTE_CHANGED, - - LAST_SIGNAL -}; - -enum -{ - PROP_0, - - PROP_ID, - PROP_FILENAME, - PROP_ATTRIBUTES -}; - -static guint signals[LAST_SIGNAL] = { 0 }; - -static void -maliit_attribute_extension_finalize (GObject *object) -{ - MaliitAttributeExtension *extension = MALIIT_ATTRIBUTE_EXTENSION (object); - MaliitAttributeExtensionPrivate *priv = extension->priv; - - g_free (priv->filename); - - G_OBJECT_CLASS (maliit_attribute_extension_parent_class)->finalize (object); -} - -static void -maliit_attribute_extension_dispose (GObject *object) -{ - MaliitAttributeExtension *extension = MALIIT_ATTRIBUTE_EXTENSION (object); - MaliitAttributeExtensionPrivate *priv = extension->priv; - - if (priv->registry) { - MaliitAttributeExtensionRegistry *registry = priv->registry; - - priv->registry = NULL; - maliit_attribute_extension_registry_remove_extension (registry, - extension); - g_object_unref (registry); - } - - if (priv->attributes) { - GHashTable *attributes = priv->attributes; - - priv->attributes = NULL; - g_hash_table_unref (attributes); - } - - G_OBJECT_CLASS (maliit_attribute_extension_parent_class)->dispose (object); -} - -static void -maliit_attribute_extension_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) -{ - MaliitAttributeExtension *extension = MALIIT_ATTRIBUTE_EXTENSION (object); - MaliitAttributeExtensionPrivate *priv = extension->priv; - - switch (prop_id) { - case PROP_ID: - priv->id = g_value_get_int (value); - break; - case PROP_FILENAME: - g_free (extension->priv->filename); - priv->filename = g_value_dup_string (value); - break; - /* PROP_ATTRIBUTES is read only. */ - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -maliit_attribute_extension_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - MaliitAttributeExtension *extension = MALIIT_ATTRIBUTE_EXTENSION (object); - MaliitAttributeExtensionPrivate *priv = extension->priv; - - switch (prop_id) { - case PROP_ID: - g_value_set_int (value, priv->id); - break; - case PROP_FILENAME: - g_value_set_string (value, priv->filename); - break; - case PROP_ATTRIBUTES: - g_value_set_boxed (value, priv->attributes); - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -maliit_attribute_extension_constructed (GObject *object) -{ - static int id_counter = 0; - MaliitAttributeExtension *extension = MALIIT_ATTRIBUTE_EXTENSION (object); - MaliitAttributeExtensionPrivate *priv = extension->priv; - - if (priv->id == 0) { - priv->id = id_counter++; - } - - maliit_attribute_extension_registry_add_extension (priv->registry, - extension); - - G_OBJECT_CLASS (maliit_attribute_extension_parent_class)->constructed (object); -} - -static void -maliit_attribute_extension_class_init (MaliitAttributeExtensionClass *extension_class) -{ - GObjectClass *g_object_class = G_OBJECT_CLASS (extension_class); - - g_object_class->finalize = maliit_attribute_extension_finalize; - g_object_class->dispose = maliit_attribute_extension_dispose; - g_object_class->set_property = maliit_attribute_extension_set_property; - g_object_class->get_property = maliit_attribute_extension_get_property; - g_object_class->constructed = maliit_attribute_extension_constructed; - - /** - * MaliitAttributeExtension:id: - * - * ID of the extension. - */ - g_object_class_install_property (g_object_class, - PROP_ID, - g_param_spec_int ("id", - "ID", /* TODO: mark as translatable? */ - "ID of the extension", /* TODO: mark as translatable? */ - G_MININT, - G_MAXINT, - 0, - G_PARAM_READABLE | - G_PARAM_WRITABLE | - G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_NAME | - G_PARAM_STATIC_BLURB | - G_PARAM_STATIC_NICK)); - - /** - * MaliitAttributeExtension:id: - * - * Path to file where definitions of overrides are defined. - */ - g_object_class_install_property (g_object_class, - PROP_FILENAME, - g_param_spec_string ("filename", - "Filename", /* TODO: mark as translatable? */ - "Filename of the extension", /* TODO: mark as translatable? */ - NULL, - G_PARAM_READABLE | - G_PARAM_WRITABLE | - G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_NAME | - G_PARAM_STATIC_BLURB | - G_PARAM_STATIC_NICK)); - - g_object_class_install_property (g_object_class, - PROP_ATTRIBUTES, - g_param_spec_boxed ("attributes", - "Attributes", /* TODO: mark as translatable? */ - "Attributes overrides", /* TODO: mark as translatable? */ - G_TYPE_HASH_TABLE, - G_PARAM_READABLE | - G_PARAM_STATIC_NAME | - G_PARAM_STATIC_BLURB | - G_PARAM_STATIC_NICK)); - - /** - * MaliitAttributeExtension::extended-attribute-changed: - * @extension: The #MaliitAttributeExtension emitting the signal. - * @key: A string specifying the target for the attribute. - * @value: A new value. - * - * Informs application that input method server has changed the - * extended attribute. - */ - signals[EXTENDED_ATTRIBUTE_CHANGED] = - g_signal_new ("extended-attribute-changed", - MALIIT_TYPE_ATTRIBUTE_EXTENSION, - G_SIGNAL_RUN_FIRST, - 0, - NULL, - NULL, - maliit_marshal_VOID__STRING_VARIANT, - G_TYPE_NONE, - 2, - G_TYPE_STRING, - G_TYPE_VARIANT); -} - -static void -maliit_attribute_extension_init (MaliitAttributeExtension *extension) -{ - MaliitAttributeExtensionPrivate *priv = maliit_attribute_extension_get_instance_private (extension); - - priv->id = 0; - priv->filename = NULL; - priv->attributes = g_hash_table_new_full (g_str_hash, - g_str_equal, - g_free, - (GDestroyNotify) g_variant_unref); - priv->registry = maliit_attribute_extension_registry_get_instance (); - - extension->priv = priv; -} - -/** - * maliit_attribute_extension_new: - * - * Creates new attribute extension, which is not associated with any file. - * - * Returns: (transfer full): The newly created - * #MaliitAttributeExtension. - */ -MaliitAttributeExtension * -maliit_attribute_extension_new (void) -{ - return MALIIT_ATTRIBUTE_EXTENSION (g_object_new (MALIIT_TYPE_ATTRIBUTE_EXTENSION, - NULL)); -} - -/** - * maliit_attribute_extension_new_with_id: (skip) - * @id: An overriden id. - * - * Creates a new attribute extension with already existing id. - * - * Returns: (transfer full): The newly created - * #MaliitAttributeExtension. - */ -MaliitAttributeExtension * -maliit_attribute_extension_new_with_id (int id) -{ - return MALIIT_ATTRIBUTE_EXTENSION (g_object_new (MALIIT_TYPE_ATTRIBUTE_EXTENSION, - "id", id, - NULL)); -} - -/** - * maliit_attribute_extension_new_with_filename: - * @filename: (transfer none) (type filename): Filename where overrides are stored. - * - * Creates new attribute extension, which is associated with file - * given as @filename. - * - * Returns: (transfer full): The newly created - * #MaliitAttributeExtension. - */ -MaliitAttributeExtension * -maliit_attribute_extension_new_with_filename (const gchar *filename) -{ - return MALIIT_ATTRIBUTE_EXTENSION (g_object_new (MALIIT_TYPE_ATTRIBUTE_EXTENSION, - "filename", filename, - NULL)); -} - -/** - * maliit_attribute_extension_get_attributes: - * @extension: (transfer none): The #MaliitAttributeExtension which attributes you want to get. - * - * Gets all attributes of this extension that were set previously with - * maliit_attribute_extension_set_attribute(). - * - * Returns: (transfer none) (element-type utf8 GLib.Variant): The #GHashTable - * containing strings as keys and #GVariants as values. Should not be - * freed nor modified. - */ -GHashTable * -maliit_attribute_extension_get_attributes (MaliitAttributeExtension *extension) -{ - g_return_val_if_fail (MALIIT_IS_ATTRIBUTE_EXTENSION (extension), NULL); - - return extension->priv->attributes; -} - -/** - * maliit_attribute_extension_get_filename: - * @extension: (transfer none): The #MaliitAttributeExtension which filename you want to get. - * - * Gets filename of this extension that were set previously with - * maliit_attribute_extension_new_with_filename(). - * - * Returns: (transfer none) (type filename): The string being a - * filename of this extension or %NULL. Returned string should not be - * freed nor modified. - */ -const gchar * -maliit_attribute_extension_get_filename (MaliitAttributeExtension *extension) -{ - g_return_val_if_fail (MALIIT_IS_ATTRIBUTE_EXTENSION (extension), NULL); - - return extension->priv->filename; -} - -/** - * maliit_attribute_extension_get_id: - * @extension: (transfer none): The #MaliitAttributeExtension which ID you want to get. - * - * Gets ID of this extension. - * - * Returns: The ID of this extension. - */ -int -maliit_attribute_extension_get_id (MaliitAttributeExtension *extension) -{ - g_return_val_if_fail (MALIIT_IS_ATTRIBUTE_EXTENSION (extension), -1); - - return extension->priv->id; -} - -/** - * maliit_attribute_extension_update_attribute: - * @extension: (transfer none): The #MaliitAttributeExtension which attribute you want to update. - * @key: (transfer none): Attribute name to update. - * @value: (transfer none): Attribute value to update. - * - * Updates the @extension's attribute described by @key with - * @value. This function always emits a - * #MaliitAttributeExtension::extended-attribute-changed signal. - */ -void -maliit_attribute_extension_update_attribute (MaliitAttributeExtension *extension, - const gchar *key, - GVariant *value) -{ - g_return_if_fail (MALIIT_IS_ATTRIBUTE_EXTENSION (extension)); - g_return_if_fail (key != NULL); - g_return_if_fail (value != NULL); - - g_hash_table_replace (extension->priv->attributes, - g_strdup (key), - g_variant_ref (value)); - - g_signal_emit (extension, - signals[EXTENDED_ATTRIBUTE_CHANGED], - 0, - key, - value); -} - -/** - * maliit_attribute_extension_set_attribute: - * @extension: (transfer none): The #MaliitAttributeExtension which attribute you want to set. - * @key: (transfer none): Attribute name to update. - * @value: (transfer none): Attribute value to update. - * - * Sets an attribute in @extension described by @key to value in @value. - */ -void maliit_attribute_extension_set_attribute (MaliitAttributeExtension *extension, - const gchar *key, - GVariant *value) -{ - MaliitAttributeExtensionPrivate *priv; - GHashTable *attributes; - GVariant *orig_value; - - g_return_if_fail (MALIIT_IS_ATTRIBUTE_EXTENSION (extension)); - g_return_if_fail (key != NULL); - g_return_if_fail (value != NULL); - - priv = extension->priv; - attributes = priv->attributes; - - if (!g_hash_table_lookup_extended (attributes, key, NULL, (gpointer *)&orig_value) || - !g_variant_equal (orig_value, value)) { - - g_hash_table_replace (attributes, - g_strdup (key), - g_variant_ref (value)); - - maliit_attribute_extension_registry_extension_changed (priv->registry, - extension, - key, - value); - } -} - -/** - * maliit_attribute_extension_attach_to_object: - * @extension: (transfer none): The #MaliitAttributeExtension which you want to be attached. - * @object: (transfer none): The #GObject to which @extension will be attached. - * - * Attaches @extension to @object, so input context can retrieve it - * from @object. Note that attaching extensions to non-input - * #GObjects does not have much sense. - */ -void -maliit_attribute_extension_attach_to_object (MaliitAttributeExtension *extension, - GObject *object) -{ - g_return_if_fail (MALIIT_IS_ATTRIBUTE_EXTENSION (extension)); - g_return_if_fail (G_IS_OBJECT (object)); - - g_object_set_qdata_full (object, MALIIT_ATTRIBUTE_EXTENSION_DATA_QUARK, - extension, g_object_unref); -} diff --git a/maliit-glib/maliitattributeextension.h b/maliit-glib/maliitattributeextension.h deleted file mode 100644 index 3876e134..00000000 --- a/maliit-glib/maliitattributeextension.h +++ /dev/null @@ -1,96 +0,0 @@ -/* This file is part of Maliit framework - * - * Copyright (C) 2012 One Laptop per Child Association - * - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the licence, or (at your option) any later version. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef MALIIT_GLIB_ATTRIBUTE_EXTENSION_H -#define MALIIT_GLIB_ATTRIBUTE_EXTENSION_H - -#include -#include - -G_BEGIN_DECLS - -#define MALIIT_ATTRIBUTE_EXTENSION_DATA "maliit-attribute-extension" - -#define MALIIT_ATTRIBUTE_EXTENSION_DATA_QUARK (g_quark_from_string (MALIIT_ATTRIBUTE_EXTENSION_DATA)) - -#define MALIIT_TYPE_ATTRIBUTE_EXTENSION (maliit_attribute_extension_get_type()) -#define MALIIT_ATTRIBUTE_EXTENSION(obj) (G_TYPE_CHECK_INSTANCE_CAST(obj, MALIIT_TYPE_ATTRIBUTE_EXTENSION, MaliitAttributeExtension)) -#define MALIIT_ATTRIBUTE_EXTENSION_CLASS(cls) (G_TYPE_CHECK_CLASS_CAST(cls, MALIIT_TYPE_ATTRIBUTE_EXTENSION, MaliitAttributeExtensionClass)) -#define MALIIT_IS_ATTRIBUTE_EXTENSION(obj) (G_TYPE_CHECK_INSTANCE_TYPE(obj, MALIIT_TYPE_ATTRIBUTE_EXTENSION)) -#define MALIIT_IS_ATTRIBUTE_EXTENSION_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE(obj, MALIIT_TYPE_ATTRIBUTE_EXTENSION)) -#define MALIIT_ATTRIBUTE_EXTENSION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), MALIIT_TYPE_ATTRIBUTE_EXTENSION, MaliitAttributeExtensionClass)) - -typedef struct _MaliitAttributeExtension MaliitAttributeExtension; -typedef struct _MaliitAttributeExtensionClass MaliitAttributeExtensionClass; -typedef struct _MaliitAttributeExtensionPrivate MaliitAttributeExtensionPrivate; - -struct _MaliitAttributeExtension -{ - GObject parent; - - /*< private >*/ - MaliitAttributeExtensionPrivate *priv; -}; - -/** - * MaliitAttributeExtensionClass: - * @parent_class: The parent class. - */ -struct _MaliitAttributeExtensionClass -{ - GObjectClass parent_class; -}; - -GType -maliit_attribute_extension_get_type (void) G_GNUC_CONST; - -MaliitAttributeExtension * -maliit_attribute_extension_new (void); - -MaliitAttributeExtension * -maliit_attribute_extension_new_with_filename (const gchar* filename); - -GHashTable * -maliit_attribute_extension_get_attributes (MaliitAttributeExtension *extension); - -const gchar * -maliit_attribute_extension_get_filename (MaliitAttributeExtension *extension); - -int -maliit_attribute_extension_get_id (MaliitAttributeExtension *extension); - -void -maliit_attribute_extension_update_attribute (MaliitAttributeExtension *extension, - const gchar *key, - GVariant *value); - -void -maliit_attribute_extension_set_attribute (MaliitAttributeExtension *extension, - const gchar *key, - GVariant *value); - -void -maliit_attribute_extension_attach_to_object (MaliitAttributeExtension *extension, - GObject *object); - -G_END_DECLS - -#endif /* MALIIT_GLIB_ATTRIBUTE_EXTENSION_H */ diff --git a/maliit-glib/maliitattributeextensionprivate.h b/maliit-glib/maliitattributeextensionprivate.h deleted file mode 100644 index dfeeed8e..00000000 --- a/maliit-glib/maliitattributeextensionprivate.h +++ /dev/null @@ -1,31 +0,0 @@ -/* This file is part of Maliit framework - * - * Copyright (C) 2012 One Laptop per Child Association - * - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the licence, or (at your option) any later version. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef MALIIT_GLIB_ATTRIBUTE_EXTENSION_PRIVATE_H -#define MALIIT_GLIB_ATTRIBUTE_EXTENSION_PRIVATE_H - -#include -#include "maliitattributeextension.h" - -MaliitAttributeExtension * -maliit_attribute_extension_new_with_id (int id); - -#endif /* MALIIT_GLIB_ATTRIBUTE_EXTENSION_PRIVATE_H */ diff --git a/maliit-glib/maliitattributeextensionregistry.c b/maliit-glib/maliitattributeextensionregistry.c deleted file mode 100644 index d8323dc1..00000000 --- a/maliit-glib/maliitattributeextensionregistry.c +++ /dev/null @@ -1,343 +0,0 @@ -/* This file is part of Maliit framework - * - * Copyright (C) 2012 One Laptop per Child Association - * - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the licence, or (at your option) any later version. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include "maliitattributeextensionregistry.h" -#include "maliitbus.h" - -struct _MaliitAttributeExtensionRegistryPrivate -{ - GHashTable *extensions; -}; - -static MaliitAttributeExtensionRegistry *global_singleton; - -G_DEFINE_TYPE_WITH_CODE (MaliitAttributeExtensionRegistry, - maliit_attribute_extension_registry, - G_TYPE_OBJECT, - G_ADD_PRIVATE (MaliitAttributeExtensionRegistry)) - -static void -maliit_attribute_extension_registry_finalize (GObject *object) -{ - global_singleton = NULL; - - G_OBJECT_CLASS (maliit_attribute_extension_registry_parent_class)->finalize (object); -} - -static void -extension_notify (gpointer data, - GObject *where_the_object_was) -{ - MaliitAttributeExtensionRegistry *registry = MALIIT_ATTRIBUTE_EXTENSION_REGISTRY (data); - MaliitAttributeExtensionRegistryPrivate *priv = registry->priv; - GHashTableIter iter; - MaliitAttributeExtension *extension; - - g_hash_table_iter_init (&iter, priv->extensions); - while (g_hash_table_iter_next (&iter, NULL, (gpointer *)&extension)) { - if ((gpointer)extension == (gpointer)where_the_object_was) { - g_hash_table_iter_steal (&iter); - break; - } - } -} - -static void -maliit_attribute_extension_registry_dispose (GObject *object) -{ - MaliitAttributeExtensionRegistry *registry = MALIIT_ATTRIBUTE_EXTENSION_REGISTRY (object); - MaliitAttributeExtensionRegistryPrivate *priv = registry->priv; - - if (priv->extensions) { - GHashTable *extensions = priv->extensions; - - priv->extensions = NULL; - g_hash_table_unref (extensions); - } - - G_OBJECT_CLASS (maliit_attribute_extension_registry_parent_class)->dispose (object); -} - -static GObject* -maliit_attribute_extension_registry_constructor (GType type, - guint n_params, - GObjectConstructParam *params) -{ - GObject *object; - - if (global_singleton) { - object = g_object_ref (G_OBJECT (global_singleton)); - } else { - object = G_OBJECT_CLASS (maliit_attribute_extension_registry_parent_class)->constructor (type, - n_params, - params); - /* We are doing an additional reference here, so object will not - * be destroyed when last owner removes its reference. This is a - * leak, but for now it ensures that singleton have a lifetime of - * application. This needs to be fixed, when object lifetimes are - * fixed in gtk-input-context. */ - global_singleton = MALIIT_ATTRIBUTE_EXTENSION_REGISTRY (g_object_ref (object)); - } - - return object; -} - -static void -maliit_attribute_extension_registry_class_init (MaliitAttributeExtensionRegistryClass *registry_class) -{ - GObjectClass *g_object_class = G_OBJECT_CLASS (registry_class); - - g_object_class->finalize = maliit_attribute_extension_registry_finalize; - g_object_class->dispose = maliit_attribute_extension_registry_dispose; - g_object_class->constructor = maliit_attribute_extension_registry_constructor; -} - -static void -extension_weak_unref (MaliitAttributeExtension *extension, - MaliitAttributeExtensionRegistry *registry) -{ - g_object_weak_unref (G_OBJECT (extension), - extension_notify, - registry); -} - -static void -extension_weak_unref_global (gpointer data) -{ - MaliitAttributeExtension *extension = MALIIT_ATTRIBUTE_EXTENSION (data); - - extension_weak_unref (extension, - global_singleton); -} - -static void -register_all_extensions (MaliitServer *server, gpointer user_data) -{ - MaliitAttributeExtensionRegistry *registry = user_data; - GList *extensions = maliit_attribute_extension_registry_get_extensions (registry); - GList *iter; - GError *error = NULL; - - for (iter = extensions; iter; iter = iter->next) { - MaliitAttributeExtension *extension = MALIIT_ATTRIBUTE_EXTENSION (iter->data); - } - - g_list_free (extensions); -} - -static void -connection_established (GObject *source_object G_GNUC_UNUSED, - GAsyncResult *res, - gpointer user_data) -{ - GError *error = NULL; - MaliitServer *server = maliit_get_server_finish (res, &error); - - if (server) { - register_all_extensions (server, user_data); - } else { - g_warning ("Unable to connect to server: %s", error->message); - g_clear_error (&error); - } -} - -static void -maliit_attribute_extension_registry_init (MaliitAttributeExtensionRegistry *registry) -{ - MaliitAttributeExtensionRegistryPrivate *priv = maliit_attribute_extension_registry_get_instance_private (registry); - - priv->extensions = g_hash_table_new_full (g_direct_hash, - g_direct_equal, - NULL, - extension_weak_unref_global); - - registry->priv = priv; - - maliit_get_server (NULL, connection_established, registry); -} - -MaliitAttributeExtensionRegistry * -maliit_attribute_extension_registry_get_instance (void) -{ - return MALIIT_ATTRIBUTE_EXTENSION_REGISTRY (g_object_new (MALIIT_TYPE_ATTRIBUTE_EXTENSION_REGISTRY, - NULL)); -} - -void -maliit_attribute_extension_registry_add_extension (MaliitAttributeExtensionRegistry *registry, - MaliitAttributeExtension *extension) -{ - MaliitServer *server; - GHashTable *extensions; - gint id; - GError *error = NULL; - - g_return_if_fail (MALIIT_IS_ATTRIBUTE_EXTENSION_REGISTRY (registry)); - g_return_if_fail (MALIIT_IS_ATTRIBUTE_EXTENSION (extension)); - - extensions = registry->priv->extensions; - id = maliit_attribute_extension_get_id (extension); - - if (!g_hash_table_lookup_extended (extensions, GINT_TO_POINTER (id), NULL, NULL)) { - g_object_weak_ref (G_OBJECT (extension), - extension_notify, - registry); - - g_hash_table_insert (extensions, - GINT_TO_POINTER (id), - extension); - - server = maliit_get_server_sync (NULL, &error); - - if (!server) { - g_warning ("Unable to connect to server: %s", error->message); - g_clear_error (&error); - } - } -} - -void -maliit_attribute_extension_registry_remove_extension (MaliitAttributeExtensionRegistry *registry, - MaliitAttributeExtension *extension) -{ - MaliitServer *server; - GHashTable *extensions; - gint id; - GError *error = NULL; - - g_return_if_fail (MALIIT_IS_ATTRIBUTE_EXTENSION_REGISTRY (registry)); - g_return_if_fail (MALIIT_IS_ATTRIBUTE_EXTENSION (extension)); - - extensions = registry->priv->extensions; - id = maliit_attribute_extension_get_id (extension); - - if (g_hash_table_lookup_extended (extensions, GINT_TO_POINTER (id), NULL, NULL)) { - g_hash_table_remove (extensions, - GINT_TO_POINTER (id)); - - server = maliit_get_server_sync (NULL, &error); - - if (!server) { - g_warning ("Unable to connect to server: %s", error->message); - g_clear_error (&error); - } - } -} - -/* For glib < 2.30 */ -#ifndef G_VALUE_INIT -#define G_VALUE_INIT { 0, { { 0 } } } -#endif - -void -maliit_attribute_extension_registry_extension_changed (MaliitAttributeExtensionRegistry *registry, - MaliitAttributeExtension *extension, - const gchar *key, - GVariant *value) -{ - MaliitServer *server; - gchar **parts; - GError *error = NULL; - - g_return_if_fail (MALIIT_IS_ATTRIBUTE_EXTENSION_REGISTRY (registry)); - g_return_if_fail (MALIIT_IS_ATTRIBUTE_EXTENSION (extension)); - g_return_if_fail (key != NULL); - g_return_if_fail (value != NULL); - - parts = g_strsplit (key + 1, "/", 3); - - if (!parts) - return; - - if (g_strv_length (parts) == 3) { - gchar *target = g_strdup_printf ("/%s", parts[0]); - - server = maliit_get_server_sync (NULL, &error); - - if (!server) { - g_warning ("Unable to connect to server: %s", error->message); - g_clear_error (&error); - } - - g_free (target); - } else { - g_warning("Key `%s' is not valid. It needs to be `/target/item/key'", key); - } - g_strfreev (parts); -} - -static void -fill_list_with_extensions (gpointer key G_GNUC_UNUSED, - gpointer value, - gpointer user_data) -{ - MaliitAttributeExtension *extension = MALIIT_ATTRIBUTE_EXTENSION (value); - GList **list = (GList **)user_data; - - *list = g_list_prepend (*list, extension); -} - -GList * -maliit_attribute_extension_registry_get_extensions (MaliitAttributeExtensionRegistry *registry) -{ - GList *list; - - g_return_val_if_fail (MALIIT_IS_ATTRIBUTE_EXTENSION_REGISTRY (registry), NULL); - - list = NULL; - g_hash_table_foreach (registry->priv->extensions, - fill_list_with_extensions, - &list); - - return list; -} - -void -maliit_attribute_extension_registry_update_attribute (MaliitAttributeExtensionRegistry *registry, - gint id, - const gchar *target, - const gchar *target_item, - const gchar *attribute, - GVariant *value) -{ - MaliitAttributeExtension *extension; - - g_return_if_fail (MALIIT_IS_ATTRIBUTE_EXTENSION_REGISTRY (registry)); - g_return_if_fail (id >= 0); - g_return_if_fail (target != NULL); - g_return_if_fail (target_item != NULL); - g_return_if_fail (attribute != NULL); - g_return_if_fail (value != NULL); - - if (g_hash_table_lookup_extended (registry->priv->extensions, - GINT_TO_POINTER (id), - NULL, - (gpointer *)&extension)) { - gchar *key = g_strdup_printf ("%s/%s/%s", target, target_item, attribute); - - maliit_attribute_extension_update_attribute (extension, - key, - value); - g_free (key); - } else { - g_warning ("Extension %d was not found.", id); - } -} diff --git a/maliit-glib/maliitattributeextensionregistry.h b/maliit-glib/maliitattributeextensionregistry.h deleted file mode 100644 index a0e0e150..00000000 --- a/maliit-glib/maliitattributeextensionregistry.h +++ /dev/null @@ -1,93 +0,0 @@ -/* This file is part of Maliit framework - * - * Copyright (C) 2012 One Laptop per Child Association - * - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the licence, or (at your option) any later version. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef MALIIT_GLIB_ATTRIBUTE_EXTENSION_REGISTRY_H -#define MALIIT_GLIB_ATTRIBUTE_EXTENSION_REGISTRY_H - -#include -#include - -#include "maliitattributeextension.h" - -G_BEGIN_DECLS - -#define MALIIT_TYPE_ATTRIBUTE_EXTENSION_REGISTRY (maliit_attribute_extension_registry_get_type()) -#define MALIIT_ATTRIBUTE_EXTENSION_REGISTRY(obj) (G_TYPE_CHECK_INSTANCE_CAST(obj, MALIIT_TYPE_ATTRIBUTE_EXTENSION_REGISTRY, MaliitAttributeExtensionRegistry)) -#define MALIIT_ATTRIBUTE_EXTENSION_REGISTRY_CLASS(cls) (G_TYPE_CHECK_CLASS_CAST(cls, MALIIT_TYPE_ATTRIBUTE_EXTENSION_REGISTRY, MaliitAttributeExtensionRegistryClass)) -#define MALIIT_IS_ATTRIBUTE_EXTENSION_REGISTRY(obj) (G_TYPE_CHECK_INSTANCE_TYPE(obj, MALIIT_TYPE_ATTRIBUTE_EXTENSION_REGISTRY)) -#define MALIIT_IS_ATTRIBUTE_EXTENSION_REGISTRY_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE(obj, MALIIT_TYPE_ATTRIBUTE_EXTENSION_REGISTRY)) -#define MALIIT_ATTRIBUTE_EXTENSION_REGISTRY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), MALIIT_TYPE_ATTRIBUTE_EXTENSION_REGISTRY, MaliitAttributeExtensionRegistryClass)) - -typedef struct _MaliitAttributeExtensionRegistry MaliitAttributeExtensionRegistry; -typedef struct _MaliitAttributeExtensionRegistryClass MaliitAttributeExtensionRegistryClass; -typedef struct _MaliitAttributeExtensionRegistryPrivate MaliitAttributeExtensionRegistryPrivate; - -struct _MaliitAttributeExtensionRegistry -{ - GObject parent; - - /*< private >*/ - MaliitAttributeExtensionRegistryPrivate *priv; -}; - -/** - * MaliitAttributeExtensionRegistryClass: - * @parent_class: The parent class. - */ -struct _MaliitAttributeExtensionRegistryClass -{ - GObjectClass parent_class; -}; - -GType -maliit_attribute_extension_registry_get_type (void) G_GNUC_CONST; - -MaliitAttributeExtensionRegistry * -maliit_attribute_extension_registry_get_instance (void); - -void -maliit_attribute_extension_registry_add_extension (MaliitAttributeExtensionRegistry *registry, - MaliitAttributeExtension *extension); - -void -maliit_attribute_extension_registry_remove_extension (MaliitAttributeExtensionRegistry *registry, - MaliitAttributeExtension *extension); - -void -maliit_attribute_extension_registry_extension_changed (MaliitAttributeExtensionRegistry *registry, - MaliitAttributeExtension *extension, - const gchar *key, - GVariant *value); - -GList * -maliit_attribute_extension_registry_get_extensions (MaliitAttributeExtensionRegistry *registry); - -void -maliit_attribute_extension_registry_update_attribute (MaliitAttributeExtensionRegistry *registry, - gint id, - const gchar *target, - const gchar *target_item, - const gchar *attribute, - GVariant *value); - -G_END_DECLS - -#endif /* MALIIT_GLIB_ATTRIBUTE_EXTENSION_REGISTRY_H */ From 489a8e20414bbae50046fce9485c37b2d155c39c Mon Sep 17 00:00:00 2001 From: Rodney Dawes Date: Wed, 15 Jun 2022 17:12:47 -0400 Subject: [PATCH 10/13] tests: Fix the mimpluginmanager plugin switcher test --- tests/ut_mimpluginmanager/ut_mimpluginmanager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/ut_mimpluginmanager/ut_mimpluginmanager.cpp b/tests/ut_mimpluginmanager/ut_mimpluginmanager.cpp index b8c3adcb..606b6eec 100644 --- a/tests/ut_mimpluginmanager/ut_mimpluginmanager.cpp +++ b/tests/ut_mimpluginmanager/ut_mimpluginmanager.cpp @@ -395,7 +395,7 @@ void Ut_MIMPluginManager::testPluginSwitcher() inputMethod3 = dynamic_cast(abstractInputMethod); QVERIFY(inputMethod3 != 0); QCOMPARE(inputMethod3->switchContextCallCount, 0); - QCOMPARE(inputMethod3->setStateCount, 1); + QVERIFY(inputMethod3->setStateCount); inputMethod3->setStateCount = 0; QCOMPARE(inputMethod3->setStateParam.size(), 1); QCOMPARE(*inputMethod3->setStateParam.begin(), state); From ac958198c7c02661a75b977b33125d5ef6c77053 Mon Sep 17 00:00:00 2001 From: Rodney Dawes Date: Thu, 16 Jun 2022 13:48:26 -0400 Subject: [PATCH 11/13] Separate the library version from the project version To make it easier to maintain things in the future in case of any ABI or API breaks, split the library versioning to a new variable. --- CMakeLists.txt | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ba35dc58..2d4fb5b3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,7 @@ cmake_minimum_required(VERSION 3.5) -project(maliit-framework VERSION 2.3.0) +project(maliit-framework VERSION 2.99.0) +set(LIBRARY_VERSION 3.0.0) # Build options @@ -203,8 +204,8 @@ target_link_libraries(maliit-plugins PRIVATE maliit-common maliit-connection ${P target_link_libraries(maliit-plugins PUBLIC Qt5::Core Qt5::Gui Qt5::Quick) target_include_directories(maliit-plugins PRIVATE ${PLUGINS_INCLUDE_DIRS}) -set_target_properties(maliit-plugins PROPERTIES SOVERSION ${PROJECT_VERSION_MAJOR} - VERSION ${PROJECT_VERSION} +set_target_properties(maliit-plugins PROPERTIES + VERSION ${LIBRARY_VERSION} EXPORT_NAME Maliit::Plugins) if(enable-glib) @@ -242,8 +243,8 @@ if(enable-glib) add_library(maliit-glib SHARED ${GLIB_SOURCES} ${GLIB_HEADER}) target_include_directories(maliit-glib PUBLIC ${GIO_INCLUDE_DIRS}) target_link_libraries(maliit-glib ${GIO_LIBRARIES}) - set_target_properties(maliit-glib PROPERTIES SOVERSION ${PROJECT_VERSION_MAJOR} - VERSION ${PROJECT_VERSION} + set_target_properties(maliit-glib PROPERTIES + VERSION ${LIBRARY_VERSION} EXPORT_NAME Maliit::GLib) endif() From e81c81068fbb8be8b9ea5f763410f7f6d25b0190 Mon Sep 17 00:00:00 2001 From: Rodney Dawes Date: Thu, 16 Jun 2022 14:49:52 -0400 Subject: [PATCH 12/13] Add FormattedNumberContentType separate from NumberContentType As formatted numbers and pure digits are separate content requirements and should have separate keyboard panels, provide the API to treat them separately, as they are treated in toolkits and wayland protocols. Fixes #31 --- common/maliit/namespace.h | 3 +++ connection/waylandinputmethodconnection.cpp | 3 ++- input-context/minputcontext.cpp | 4 +++- src/quick/maliitquick.h | 1 + 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/common/maliit/namespace.h b/common/maliit/namespace.h index 13e411bc..42e5985d 100644 --- a/common/maliit/namespace.h +++ b/common/maliit/namespace.h @@ -44,6 +44,9 @@ namespace Maliit { //! only integer numbers allowed NumberContentType, + //! only numbers and formatted characters + FormattedNumberContentType, + //! allows numbers and certain other characters used in phone numbers PhoneNumberContentType, diff --git a/connection/waylandinputmethodconnection.cpp b/connection/waylandinputmethodconnection.cpp index bef77287..1f4b066f 100644 --- a/connection/waylandinputmethodconnection.cpp +++ b/connection/waylandinputmethodconnection.cpp @@ -137,8 +137,9 @@ Maliit::TextContentType contentTypeFromWayland(uint32_t purpose) case QtWayland::zwp_text_input_v2::content_purpose_normal: return Maliit::FreeTextContentType; case QtWayland::zwp_text_input_v2::content_purpose_digits: - case QtWayland::zwp_text_input_v2::content_purpose_number: return Maliit::NumberContentType; + case QtWayland::zwp_text_input_v2::content_purpose_number: + return Maliit::FormattedNumberContentType; case QtWayland::zwp_text_input_v2::content_purpose_phone: return Maliit::PhoneNumberContentType; case QtWayland::zwp_text_input_v2::content_purpose_url: diff --git a/input-context/minputcontext.cpp b/input-context/minputcontext.cpp index dfe0df96..5984d135 100644 --- a/input-context/minputcontext.cpp +++ b/input-context/minputcontext.cpp @@ -643,8 +643,10 @@ Maliit::TextContentType MInputContext::contentType(Qt::InputMethodHints hints) c Maliit::TextContentType type = Maliit::FreeTextContentType; hints &= Qt::ImhExclusiveInputMask; - if (hints == Qt::ImhFormattedNumbersOnly || hints == Qt::ImhDigitsOnly) { + if ( hints == Qt::ImhDigitsOnly) { type = Maliit::NumberContentType; + } else if (hints == Qt::ImhFormattedNumbersOnly) { + type = Maliit::FormattedNumberContentType; } else if (hints == Qt::ImhDialableCharactersOnly) { type = Maliit::PhoneNumberContentType; } else if (hints == Qt::ImhEmailCharactersOnly) { diff --git a/src/quick/maliitquick.h b/src/quick/maliitquick.h index dba8f5d2..42776b18 100644 --- a/src/quick/maliitquick.h +++ b/src/quick/maliitquick.h @@ -37,6 +37,7 @@ class MaliitQuick: public QObject enum ContentType { FreeTextContentType = Maliit::FreeTextContentType, NumberContentType = Maliit::NumberContentType, + FormattedNumberContentType = Maliit::FormattedNumberContentType, PhoneNumberContentType = Maliit::PhoneNumberContentType, EmailContentType = Maliit::EmailContentType, UrlContentType = Maliit::UrlContentType, From 57b17c283a0d58c3897519f3b8861f3938e8bc2b Mon Sep 17 00:00:00 2001 From: Rodney Dawes Date: Thu, 30 Jun 2022 16:25:46 -0400 Subject: [PATCH 13/13] Remove MImExtensionEvent and related API --- CMakeLists.txt | 8 -- .../cxx/helloworld/helloworldinputmethod.h | 1 - .../cxx/override/overrideinputmethod.h | 1 - src/maliit/plugins/abstractinputmethod.cpp | 6 - src/maliit/plugins/abstractinputmethod.h | 13 -- src/maliit/plugins/extensionevent.cpp | 43 ------- src/maliit/plugins/extensionevent.h | 55 --------- src/maliit/plugins/extensionevent_p.h | 26 ---- src/maliit/plugins/updateevent.cpp | 111 ------------------ src/maliit/plugins/updateevent.h | 81 ------------- src/maliit/plugins/updateevent_p.h | 42 ------- src/maliit/plugins/updatereceiver.cpp | 90 -------------- src/maliit/plugins/updatereceiver.h | 74 ------------ src/maliit/standaloneinputmethod.cpp | 7 -- src/mimpluginmanager.cpp | 7 -- 15 files changed, 565 deletions(-) delete mode 100644 src/maliit/plugins/extensionevent.cpp delete mode 100644 src/maliit/plugins/extensionevent.h delete mode 100644 src/maliit/plugins/extensionevent_p.h delete mode 100644 src/maliit/plugins/updateevent.cpp delete mode 100644 src/maliit/plugins/updateevent.h delete mode 100644 src/maliit/plugins/updateevent_p.h delete mode 100644 src/maliit/plugins/updatereceiver.cpp delete mode 100644 src/maliit/plugins/updatereceiver.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 2d4fb5b3..f7d310d9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -113,9 +113,6 @@ set(PLUGINS_SOURCES src/maliit/plugins/abstractinputmethod.h src/maliit/plugins/abstractinputmethodhost.cpp src/maliit/plugins/abstractinputmethodhost.h - src/maliit/plugins/extensionevent.cpp - src/maliit/plugins/extensionevent.h - src/maliit/plugins/extensionevent_p.h src/maliit/plugins/inputmethodplugin.h src/maliit/plugins/keyoverride.cpp src/maliit/plugins/keyoverride.h @@ -126,11 +123,6 @@ set(PLUGINS_SOURCES src/maliit/plugins/plugindescription.h src/maliit/plugins/subviewdescription.cpp src/maliit/plugins/subviewdescription.h - src/maliit/plugins/updateevent.cpp - src/maliit/plugins/updateevent.h - src/maliit/plugins/updateevent_p.h - src/maliit/plugins/updatereceiver.cpp - src/maliit/plugins/updatereceiver.h src/maliit/standaloneinputmethod.cpp src/maliit/standaloneinputmethod.h src/maliit/standaloneinputmethodhost.cpp diff --git a/examples/plugins/cxx/helloworld/helloworldinputmethod.h b/examples/plugins/cxx/helloworld/helloworldinputmethod.h index ca87bd4c..7ef6dc2e 100644 --- a/examples/plugins/cxx/helloworld/helloworldinputmethod.h +++ b/examples/plugins/cxx/helloworld/helloworldinputmethod.h @@ -54,7 +54,6 @@ class HelloWorldInputMethod /* Optional, rarely used */ /* Using default implementations - virtual bool imExtensionEvent(MImExtensionEvent *event); virtual void showLanguageNotification(); virtual void setKeyOverrides(const QMap > &overrides); virtual void processKeyEvent(QEvent::Type keyType, Qt::Key keyCode, diff --git a/examples/plugins/cxx/override/overrideinputmethod.h b/examples/plugins/cxx/override/overrideinputmethod.h index e9c0dd4c..9566bac9 100644 --- a/examples/plugins/cxx/override/overrideinputmethod.h +++ b/examples/plugins/cxx/override/overrideinputmethod.h @@ -58,7 +58,6 @@ class OverrideInputMethod /* Optional, rarely used */ /* Using default implementations - virtual bool imExtensionEvent(MImExtensionEvent *event); virtual void showLanguageNotification(); virtual void processKeyEvent(QEvent::Type keyType, Qt::Key keyCode, Qt::KeyboardModifiers modifiers, const QString &text, diff --git a/src/maliit/plugins/abstractinputmethod.cpp b/src/maliit/plugins/abstractinputmethod.cpp index 0ee8511a..f2ae7c7d 100644 --- a/src/maliit/plugins/abstractinputmethod.cpp +++ b/src/maliit/plugins/abstractinputmethod.cpp @@ -180,9 +180,3 @@ void MAbstractInputMethod::setKeyOverrides(const QMap > &overrides); - /*! - * \brief handles extension event not covered by a dedicated method. - * - * Must return true if event is handled, otherwise false. - * Extensions can be registered on the application side, and will be passed through to - * the input method, allowing to add integration points between application and input method. - * Reimplementing this method is optional. - * - * \param event event to handle - */ - virtual bool imExtensionEvent(MImExtensionEvent *event); - Q_SIGNALS: /*! * \brief Inform that active subview is changed to \a subViewId for \a state. diff --git a/src/maliit/plugins/extensionevent.cpp b/src/maliit/plugins/extensionevent.cpp deleted file mode 100644 index 08f16ff1..00000000 --- a/src/maliit/plugins/extensionevent.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/* * This file is part of Maliit framework * - * - * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). - * All rights reserved. - * - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License version 2.1 as published by the Free Software Foundation - * and appearing in the file LICENSE.LGPL included in the packaging - * of this file. - */ - -#include -#include - -MImExtensionEventPrivate::~MImExtensionEventPrivate() -{} - -MImExtensionEvent::MImExtensionEvent(Type type) - : d_ptr(new MImExtensionEventPrivate) -{ - d_ptr->type = type; -} - -MImExtensionEvent::MImExtensionEvent(MImExtensionEventPrivate *dd, - Type type) - : d_ptr(dd) -{ - d_ptr->type = type; -} - -MImExtensionEvent::~MImExtensionEvent() -{ - Q_D(MImExtensionEvent); - delete d; -} - -MImExtensionEvent::Type MImExtensionEvent::type() const -{ - Q_D(const MImExtensionEvent); - return d->type; -} diff --git a/src/maliit/plugins/extensionevent.h b/src/maliit/plugins/extensionevent.h deleted file mode 100644 index 5844b097..00000000 --- a/src/maliit/plugins/extensionevent.h +++ /dev/null @@ -1,55 +0,0 @@ -/* * This file is part of Maliit framework * - * - * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). - * All rights reserved. - * - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License version 2.1 as published by the Free Software Foundation - * and appearing in the file LICENSE.LGPL included in the packaging - * of this file. - */ - -#ifndef MIMEXTENSIONEVENT_H -#define MIMEXTENSIONEVENT_H - -#include - -class MImExtensionEventPrivate; - -/*! \ingroup pluginapi - * \brief Base class for extending signaling from input method system to - * plugins. - * - * This event can be subclassed for future additions. - * - * \sa MAbstractInputMethod::imExtensionEvent(MImExtensionEvent *event) - */ -class MImExtensionEvent -{ -public: - //! Defines valid types for input method extension event - enum Type { - None, - Update - }; - - explicit MImExtensionEvent(Type type); - virtual ~MImExtensionEvent(); - - //! Returns the type of the event - Type type() const; - -protected: - MImExtensionEvent(MImExtensionEventPrivate *dd, - Type type); - - MImExtensionEventPrivate * const d_ptr; - -private: - Q_DISABLE_COPY(MImExtensionEvent) - Q_DECLARE_PRIVATE(MImExtensionEvent) -}; - -#endif diff --git a/src/maliit/plugins/extensionevent_p.h b/src/maliit/plugins/extensionevent_p.h deleted file mode 100644 index fe4e73ea..00000000 --- a/src/maliit/plugins/extensionevent_p.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef MIMEXTENSIONEVENT_P_H -#define MIMEXTENSIONEVENT_P_H - -/* * This file is part of Maliit framework * - * - * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). - * All rights reserved. - * - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License version 2.1 as published by the Free Software Foundation - * and appearing in the file LICENSE.LGPL included in the packaging - * of this file. - */ - -#include - -class MImExtensionEventPrivate -{ -public: - virtual ~MImExtensionEventPrivate(); - - MImExtensionEvent::Type type; -}; -#endif // MIMEXTENSIONEVENT_P_H diff --git a/src/maliit/plugins/updateevent.cpp b/src/maliit/plugins/updateevent.cpp deleted file mode 100644 index b1f58e02..00000000 --- a/src/maliit/plugins/updateevent.cpp +++ /dev/null @@ -1,111 +0,0 @@ -/* * This file is part of Maliit framework * - * - * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). - * All rights reserved. - * - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License version 2.1 as published by the Free Software Foundation - * and appearing in the file LICENSE.LGPL included in the packaging - * of this file. - */ - -#include -#include -#include -#include -#include - -MImUpdateEventPrivate::MImUpdateEventPrivate() - : update() - , changedProperties() - , lastHints(Qt::ImhNone) -{} - -MImUpdateEventPrivate::MImUpdateEventPrivate(const QMap &newUpdate, - const QStringList &newChangedProperties, - const Qt::InputMethodHints &newLastHints) - : update(newUpdate) - , changedProperties(newChangedProperties) - , lastHints(newLastHints) -{} - -bool MImUpdateEventPrivate::isFlagSet(Qt::InputMethodHint hint, - bool *changed) const -{ - bool result = false; - - if (update.contains(Maliit::Internal::inputMethodHints)) { - const Qt::InputMethodHints hints(static_cast( - update.value(Maliit::Internal::inputMethodHints).toInt())); - - result = (hints & hint); - } - - if (changed) { - *changed = (result != ((lastHints & hint) != 0)); - } - - return result; -} - -QVariant MImUpdateEventPrivate::extractProperty(const QString &key, - bool *changed) const -{ - if (changed) { - *changed = changedProperties.contains(key); - } - - return update.value(key); -} - -MImUpdateEvent::MImUpdateEvent(const QMap &update, - const QStringList &changedProperties) - : MImExtensionEvent(new MImUpdateEventPrivate(update, changedProperties, Qt::InputMethodHints()), - MImExtensionEvent::Update) -{} - -MImUpdateEvent::MImUpdateEvent(const QMap &update, - const QStringList &changedProperties, - const Qt::InputMethodHints &lastHints) - : MImExtensionEvent(new MImUpdateEventPrivate(update, changedProperties, lastHints), - MImExtensionEvent::Update) -{} - -QVariant MImUpdateEvent::value(const QString &key) const -{ - Q_D(const MImUpdateEvent); - return d->update.value(key); -} - -QStringList MImUpdateEvent::propertiesChanged() const -{ - Q_D(const MImUpdateEvent); - return d->changedProperties; -} - -Qt::InputMethodHints MImUpdateEvent::hints(bool *changed) const -{ - Q_D(const MImUpdateEvent); - return static_cast( - d->extractProperty(Maliit::Internal::inputMethodHints, changed).toInt()); -} - -bool MImUpdateEvent::westernNumericInputEnforced(bool *changed) const -{ - Q_D(const MImUpdateEvent); - return d->extractProperty(Maliit::InputMethodQuery::westernNumericInputEnforced, changed).toBool(); -} - -bool MImUpdateEvent::preferNumbers(bool *changed) const -{ - Q_D(const MImUpdateEvent); - return d->isFlagSet(Qt::ImhPreferNumbers, changed); -} - -bool MImUpdateEvent::translucentInputMethod(bool *changed) const -{ - Q_D(const MImUpdateEvent); - return d->extractProperty(Maliit::InputMethodQuery::translucentInputMethod, changed).toBool(); -} diff --git a/src/maliit/plugins/updateevent.h b/src/maliit/plugins/updateevent.h deleted file mode 100644 index aab34f83..00000000 --- a/src/maliit/plugins/updateevent.h +++ /dev/null @@ -1,81 +0,0 @@ -/* * This file is part of Maliit framework * - * - * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). - * All rights reserved. - * - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License version 2.1 as published by the Free Software Foundation - * and appearing in the file LICENSE.LGPL included in the packaging - * of this file. - */ - -#ifndef MIMUPDATEEVENT_H -#define MIMUPDATEEVENT_H - -#include - -#include - -class MImUpdateEventPrivate; -class MImUpdateReceiver; - -/*! \ingroup pluginapi - * \brief Monitor the input method properties sent by the application. - */ -class MImUpdateEvent - : public MImExtensionEvent -{ -public: - //! C'tor - //! \param update the map containing all properties. - //! \param propertiesChanged a string list of changed properties. - explicit MImUpdateEvent(const QMap &update, - const QStringList &propertiesChanged); - - //! C'tor - //! \param update the map containing all properties. - //! \param propertiesChanged a string list of changed properties. - //! \param lastHints the last input method hints, as compared to the new - //! ones in the updates map. Necessary to detect whether a flag - //! flipped between update event. - explicit MImUpdateEvent(const QMap &update, - const QStringList &propertiesChanged, - const Qt::InputMethodHints &lastHints); - - //! Returns invalid QVariant if key is invalid. - QVariant value(const QString &key) const; - - //! Returns list of keys that have changed, compared to last update event. - QStringList propertiesChanged() const; - - //! Returns the focus widget's input method hints. - //! \param changed whether this value changed with this event. - Qt::InputMethodHints hints(bool *changed = 0) const; - - //! Returns whether western numeric input should be shown, overridding - //! language-specific numeric inputs. - //! False by default. - //! \param changed whether this value changed with this event. - bool westernNumericInputEnforced(bool *changed = 0) const; - - //! Returns whether input field has Qt::ImhPreferNumbers hint set. - //! False by default. - //! \param changed whether this value changed with this event. - bool preferNumbers(bool *changed = 0) const; - - //! Returns whether the input method should be styled translucently. Useful - //! when apps need to display a lot of information, for example terminals. - //! False by default. - //! \param changed whether this value changed with this event. - bool translucentInputMethod(bool *changed = 0) const; - -private: - Q_DISABLE_COPY(MImUpdateEvent) - Q_DECLARE_PRIVATE(MImUpdateEvent) - - friend class MImUpdateReceiver; // Allows receiver to copy PIMPL instance. -}; - -#endif // MIMUPDATEEVENT_H diff --git a/src/maliit/plugins/updateevent_p.h b/src/maliit/plugins/updateevent_p.h deleted file mode 100644 index b3b07995..00000000 --- a/src/maliit/plugins/updateevent_p.h +++ /dev/null @@ -1,42 +0,0 @@ -/* * This file is part of Maliit framework * - * - * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). - * All rights reserved. - * - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License version 2.1 as published by the Free Software Foundation - * and appearing in the file LICENSE.LGPL included in the packaging - * of this file. - */ - -#ifndef MIMUPDATEEVENT_P_H -#define MIMUPDATEEVENT_P_H - -#include - -#include - -class MImUpdateEventPrivate - : public MImExtensionEventPrivate -{ -public: - QMap update; - QStringList changedProperties; - Qt::InputMethodHints lastHints; - - explicit MImUpdateEventPrivate(); - - explicit MImUpdateEventPrivate(const QMap &newUpdate, - const QStringList &newChangedProperties, - const Qt::InputMethodHints &newLastHints); - - bool isFlagSet(Qt::InputMethodHint hint, - bool *changed = 0) const; - - QVariant extractProperty(const QString &key, - bool *changed = 0) const; -}; - -#endif // MIMUPDATEEVENT_P_H diff --git a/src/maliit/plugins/updatereceiver.cpp b/src/maliit/plugins/updatereceiver.cpp deleted file mode 100644 index ac642b42..00000000 --- a/src/maliit/plugins/updatereceiver.cpp +++ /dev/null @@ -1,90 +0,0 @@ -/* * This file is part of Maliit framework * - * - * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). - * All rights reserved. - * - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License version 2.1 as published by the Free Software Foundation - * and appearing in the file LICENSE.LGPL included in the packaging - * of this file. - */ - -#include - -#include -#include -#include -#include -#include - -// Choosing inheritance instead of typedef, as we might want to add -// receiver-specific data later. -class MImUpdateReceiverPrivate - : public MImUpdateEventPrivate -{}; - -MImUpdateReceiver::MImUpdateReceiver(QObject *parent) - : QObject(parent) - , d_ptr(new MImUpdateReceiverPrivate) -{} - -MImUpdateReceiver::~MImUpdateReceiver() -{ - // TODO: Find out why using QScopedPointer for the PIMPL fails to compile. - delete d_ptr; -} - -void MImUpdateReceiver::process(MImUpdateEvent *ev) -{ - if (not ev) { - return; - } - - // TODO: Replace this ever-growing, switch-like structure with a more - // concise solution, based on Qt reflection (via QMetaObject and Qt - // properties). - Q_D(MImUpdateReceiver); - d->changedProperties = ev->d_func()->changedProperties; - d->update = ev->d_func()->update; - - bool changed = false; - bool value = ev->westernNumericInputEnforced(&changed); - - if (changed) { - Q_EMIT westernNumericInputEnforcedChanged(value); - } - - changed = false; - value = ev->preferNumbers(&changed); - - if (changed) { - Q_EMIT preferNumbersChanged(value); - } - - changed = false; - value = ev->translucentInputMethod(&changed); - - if (changed) { - Q_EMIT translucentInputMethodChanged(value); - } -} - -bool MImUpdateReceiver::westernNumericInputEnforced() const -{ - Q_D(const MImUpdateReceiver); - return d->extractProperty(Maliit::InputMethodQuery::westernNumericInputEnforced).toBool(); -} - -bool MImUpdateReceiver::preferNumbers() const -{ - Q_D(const MImUpdateReceiver); - return d->isFlagSet(Qt::ImhPreferNumbers); -} - -bool MImUpdateReceiver::translucentInputMethod() const -{ - Q_D(const MImUpdateReceiver); - return d->extractProperty(Maliit::InputMethodQuery::translucentInputMethod).toBool(); -} diff --git a/src/maliit/plugins/updatereceiver.h b/src/maliit/plugins/updatereceiver.h deleted file mode 100644 index 244a7427..00000000 --- a/src/maliit/plugins/updatereceiver.h +++ /dev/null @@ -1,74 +0,0 @@ -/* * This file is part of Maliit framework * - * - * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). - * All rights reserved. - * - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License version 2.1 as published by the Free Software Foundation - * and appearing in the file LICENSE.LGPL included in the packaging - * of this file. - */ - -#ifndef MIMUPDATERECEIVER_H -#define MIMUPDATERECEIVER_H - -#include - -class MImUpdateReceiverPrivate; -class MImUpdateEvent; - -/*! \ingroup pluginapi - * \brief An example that turns data-polling from events into data-pushing via - * properties and change notifications. - * - * Used in combination with MImUpdateEvents: The event is propagated down to - * the final component, where it is then processed by an event receiver. The - * receiver therefore acts as an endpoint for events, allowing the actual - * consumers of input method properties to listen to property changes. Using - * this approach, consumers are completely decoupled from the event propagation - * itself. Event receivers implemented in plugins are supposed to be more - * specialized than the generic MImUpdateReceiver. They can be designed to only - * carry the properties that are required for a given endpoint. The life time - * of event receivers usually exceeds the life time of events, which makes it - * possible to keep signal connections between consumers and event receivers - * alive. - */ -class MImUpdateReceiver - : public QObject -{ - Q_OBJECT - Q_DISABLE_COPY(MImUpdateReceiver) - Q_DECLARE_PRIVATE(MImUpdateReceiver) - - Q_PROPERTY(bool westernNumericInputEnforced - READ westernNumericInputEnforced - NOTIFY westernNumericInputEnforcedChanged) - Q_PROPERTY(bool preferNumbers - READ preferNumbers - NOTIFY preferNumbersChanged) - Q_PROPERTY(bool translucentInputMethod - READ translucentInputMethod - NOTIFY translucentInputMethodChanged) - -public: - explicit MImUpdateReceiver(QObject *parent = 0); - virtual ~MImUpdateReceiver(); - - void process(MImUpdateEvent *ev); - - bool westernNumericInputEnforced() const; - bool preferNumbers() const; - bool translucentInputMethod() const; - -Q_SIGNALS: - void westernNumericInputEnforcedChanged(bool value); - void preferNumbersChanged(bool value); - void translucentInputMethodChanged(bool value); - -private: - MImUpdateReceiverPrivate *const d_ptr; -}; - -#endif // MIMUPDATERECEIVER_H diff --git a/src/maliit/standaloneinputmethod.cpp b/src/maliit/standaloneinputmethod.cpp index 45008a27..cea629ea 100644 --- a/src/maliit/standaloneinputmethod.cpp +++ b/src/maliit/standaloneinputmethod.cpp @@ -20,7 +20,6 @@ #include "maliit/plugins/abstractinputmethod.h" #include "maliit/plugins/inputmethodplugin.h" -#include #include #include @@ -107,13 +106,7 @@ void StandaloneInputMethod::handleWidgetStateChanged(unsigned int, mInputMethod->handleVisualizationPriorityChange(newVisualization); } - const Qt::InputMethodHints lastHints = newState.value(Maliit::Internal::inputMethodHints).value(); - MImUpdateEvent ev(newState, changedProperties, lastHints); - // general notification last - if (!changedProperties.isEmpty()) { - mInputMethod->imExtensionEvent(&ev); - } mInputMethod->update(); // Make sure windows get hidden when no longer focus diff --git a/src/mimpluginmanager.cpp b/src/mimpluginmanager.cpp index 2f4fef5d..e6ce54ec 100644 --- a/src/mimpluginmanager.cpp +++ b/src/mimpluginmanager.cpp @@ -19,7 +19,6 @@ #include #include "mimsettings.h" #include "mimhwkeyboardtracker.h" -#include #include "mimsubviewoverride.h" #include "maliit/namespaceinternal.h" #include "windowgroup.h" @@ -1311,14 +1310,8 @@ void MIMPluginManager::handleWidgetStateChanged(unsigned int clientId, } } - const Qt::InputMethodHints lastHints = static_cast(newState.value(Maliit::Internal::inputMethodHints).toInt()); - MImUpdateEvent ev(newState, changedProperties, lastHints); - // general notification last Q_FOREACH (MAbstractInputMethod *target, targets()) { - if (not changedProperties.isEmpty()) { - (void) target->imExtensionEvent(&ev); - } target->update(); }