./ 0000755 0000156 0000165 00000000000 12704153516 011101 5 ustar jenkins jenkins ./docs/ 0000755 0000156 0000165 00000000000 12704153516 012031 5 ustar jenkins jenkins ./docs/devel/ 0000755 0000156 0000165 00000000000 12704153516 013130 5 ustar jenkins jenkins ./docs/devel/hud-docs.xml 0000644 0000156 0000165 00000003320 12704153516 015356 0 ustar jenkins jenkins
]>
hud-service Hacking GuideData TypesQueries, Results, ItemsSourcesUtility APIObject HierarchyAPI IndexIndex of deprecated API
./docs/devel/hud-sections.txt 0000644 0000156 0000165 00000005770 12704153516 016307 0 ustar jenkins jenkins hudsettings
HudSettings
hud_settings
hud_settings_init
hudappmenuregistrar
HudAppMenuRegistrar
HudAppMenuRegistrarObserverFunc
hud_app_menu_registrar_add_observer
hud_app_menu_registrar_get
hud_app_menu_registrar_remove_observer
HUD_APP_MENU_REGISTRAR
HUD_IS_APP_MENU_REGISTRAR
HUD_TYPE_APP_MENU_REGISTRAR
hud_app_menu_registrar_get_type
huddbusmenucollector
HudDbusmenuCollector
hud_dbusmenu_collector_new_for_endpoint
hud_dbusmenu_collector_new_for_window
hud_dbusmenu_collector_set_prefix
HUD_DBUSMENU_COLLECTOR
HUD_IS_DBUSMENU_COLLECTOR
HUD_TYPE_DBUSMENU_COLLECTOR
hud_dbusmenu_collector_get_type
hudindicatorsource
HudIndicatorSource
hud_indicator_source_new
HUD_INDICATOR_SOURCE
HUD_IS_INDICATOR_SOURCE
HUD_TYPE_INDICATOR_SOURCE
hud_indicator_source_get_type
hudappindicatorsource
HudAppIndicatorSource
hud_app_indicator_source_new
HUD_APP_INDICATOR_SOURCE
HUD_IS_APP_INDICATOR_SOURCE
HUD_TYPE_APP_INDICATOR_SOURCE
hud_app_indicator_source_get_type
huditemHudItem
HudItem
HudItemClass
hud_item_activate
hud_item_construct
hud_item_get_app_icon
hud_item_get_enabled
hud_item_get_item_icon
hud_item_get_tokens
hud_item_get_usage
hud_item_new
HUD_IS_ITEM
HUD_IS_ITEM_CLASS
HUD_ITEM
HUD_ITEM_CLASS
HUD_ITEM_GET_CLASS
HUD_TYPE_ITEM
HudItemPrivate
hud_item_get_type
hudmenumodelcollector
HudMenuModelCollector
hud_menu_model_collector_get
HUD_IS_MENU_MODEL_COLLECTOR
HUD_MENU_MODEL_COLLECTOR
HUD_TYPE_MENU_MODEL_COLLECTOR
hud_menu_model_collector_get_type
hudquery
HudQuery
hud_query_close
hud_query_get_generation
hud_query_get_n_results
hud_query_get_query_key
hud_query_get_result_by_index
hud_query_lookup
hud_query_new
HUD_IS_QUERY
HUD_QUERY
HUD_TYPE_QUERY
hud_query_get_type
hudresult
HudResult
hud_result_get_distance
hud_result_get_html_description
hud_result_get_if_matched
hud_result_get_item
hud_result_new
HUD_IS_RESULT
HUD_RESULT
HUD_TYPE_RESULT
hud_result_get_type
hudsourceHudSource
HudSource
HudSourceInterface
hud_source_changed
hud_source_search
HUD_IS_SOURCE
HUD_SOURCE
HUD_SOURCE_GET_IFACE
HUD_TYPE_SOURCE
hud_source_get_type
hudsourcelist
HudSourceList
hud_source_list_add
hud_source_list_new
HUD_IS_SOURCE_LIST
HUD_SOURCE_LIST
HUD_TYPE_SOURCE_LIST
hud_source_list_get_type
hudstringlist
HudStringList
hud_string_list_cons
hud_string_list_cons_label
hud_string_list_get_head
hud_string_list_get_tail
hud_string_list_pretty_print
hud_string_list_ref
hud_string_list_unref
./docs/devel/hud.types 0000644 0000156 0000165 00000000410 12704153516 014771 0 ustar jenkins jenkins hud_app_indicator_source_get_type
hud_app_menu_registrar_get_type
hud_dbusmenu_collector_get_type
hud_indicator_source_get_type
hud_item_get_type
hud_menu_model_collector_get_type
hud_query_get_type
hud_result_get_type
hud_source_get_type
hud_source_list_get_type
./docs/devel/hud-overview.xml 0000644 0000156 0000165 00000012310 12704153516 016273 0 ustar jenkins jenkins
Overview
The HUD consists of the interface in the shell and a backend service, hud-service. This
document attempts to describe the internal architecture of the service.
The most important type in the service is HudSource. This is
an interface. Each source is an entity against which a search can be performed. There is one interface
method: hud_source_search(). This is the main
mechanism by which queries are performed in the HUD. The interface also features a signal
::changed that is emitted when the result of
searching may have changed.
Several implementations of HudSource exist. A particular type
of source that gathers possible search results is referred to as a "collector". There are two of these:
HudMenuModelCollector (for
GDBusMenuModel) and
HudDbusmenuCollector for Dbusmenu. These
"collector" sources only function when targetted at a particular endpoint (ie: a unique name and object path
on D-Bus). This is only useful for searching for items in one particular set of menus.
HudWindowSource acts as a multiplexer. It is responsible
for determining the currently focused window and performing searches submitted to it against the correct
collector for that window. Similarly, there are
HudIndicatorSource and
HudAppIndicatorSource for performing searches against the
system and application indicators, respectively.
Finally, there is HudSourceList which functions as a list
of multiple other HudSources (such that performing a search
against the list gives the combined result of searches performed against each of the contained sources).
The hud-service initialises itself by creating the window, indicator and appindicator
sources and putting each of them into a HudSourceList.
This is the source against which all queries submitted to the service are executed.
Collectors are essentially a collection of HudItems. Each item
corresponds to an action that may appear in the results of a search made with the HUD. Items have a list of
strings describing themselves (eg: ['File', 'Open'] or
['Bluetooth', 'Settings...']) and some information about their origin (eg: the desktop
file of the application or indicator that created them). An item can be disabled, in which case it will
never appear in the results of a search. Items are activated using
hud_item_activate() which is implemented by
the collector in the appropriate way.
The result of performing a search is a set of HudResults.
Each result refers to HudItem along with information about why
that item matched, and how closely.
The toplevel interface to performing a query is HudQuery. It
takes a search string and a reference to a HudSource to search
(which, as implemented, is always the toplevel 'list' source). It submits the search to the source then
sorts the results by relevence. If the source changes, it resubmits the search. The interface of
HudQuery is an ordered sequence of results.
HudQuery has its own
::changed signal.
hud-service is essentially a simple D-Bus interface corresponding to
HudQuery as used against the toplevel source list. New queries
can be created using StartQuery. Queries can be destroyed using
CloseQuery. HudItems corresponding to
results from the query can be activated using ExecuteQuery. Finally, the
::changed signal is reported as the
UpdatedQuery D-Bus signal.
./docs/HUD Architecture.svg 0000644 0000156 0000165 00000126247 12704153516 015611 0 ustar jenkins jenkins
./docs/man/ 0000755 0000156 0000165 00000000000 12704153516 012604 5 ustar jenkins jenkins ./docs/man/hud-list-applications.xml 0000644 0000156 0000165 00000001712 12704153516 017544 0 ustar jenkins jenkins hud-list-applications1User Commandshud-list-applicationsTool to list the applications in the HUD usage databasehud-list-applicationsAUTHOR
Written by Ted Gould ted@canonical.com and others.
BUGS
Bugs should be submitted to Launchpad: SEE ALSOhud-dump-application1
./docs/man/hud-cli.xml 0000644 0000156 0000165 00000001520 12704153516 014651 0 ustar jenkins jenkins hud-cli1User Commandshud-cliTool to exercise the HUD on the command linehud-clihud-clisearch stringAUTHOR
Written by Ted Gould ted@canonical.com and others.
BUGS
Bugs should be submitted to Launchpad:
./docs/man/hud-verify-app-info.xml 0000644 0000156 0000165 00000001546 12704153516 017125 0 ustar jenkins jenkins hud-verify-app-info1User Commandshud-verify-app-infoTool to verify an app-info file that is expected to be used in the HUDhud-verify-app-infopath to app info fileAUTHOR
Written by Ted Gould ted@canonical.com and others.
BUGS
Bugs should be submitted to Launchpad:
./docs/man/CMakeLists.txt 0000644 0000156 0000165 00000001426 12704153516 015347 0 ustar jenkins jenkins
find_program(XSLTPROC_EXECUTABLE xsltproc)
macro(add_manpage name)
add_custom_command(
OUTPUT
"${CMAKE_CURRENT_BINARY_DIR}/${name}.1"
COMMAND
${XSLTPROC_EXECUTABLE}
-nonet http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl
"${CMAKE_CURRENT_SOURCE_DIR}/${name}.xml"
DEPENDS
"${CMAKE_CURRENT_SOURCE_DIR}/${name}.xml"
)
add_custom_target(${name}-man DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/${name}.1")
add_dependencies(man-pages ${name}-man)
install(
FILES "${CMAKE_CURRENT_BINARY_DIR}/${name}.1"
DESTINATION "${CMAKE_INSTALL_MANDIR}/man1"
)
endmacro()
add_custom_target(man-pages ALL)
add_manpage(hud-cli)
add_manpage(hud-dump-application)
add_manpage(hud-list-applications)
add_manpage(hud-verify-app-info)
./docs/man/hud-dump-application.xml 0000644 0000156 0000165 00000002037 12704153516 017354 0 ustar jenkins jenkins hud-dump-application1User Commandshud-dump-applicationTool to dump information on an application from the HUD usage databasehud-dump-applicationdesktop file pathAUTHOR
Written by Ted Gould ted@canonical.com and others.
BUGS
Bugs should be submitted to Launchpad: SEE ALSOhud-list-applications1
./docs/libhud/ 0000755 0000156 0000165 00000000000 12704153516 013300 5 ustar jenkins jenkins ./docs/libhud/libhud-docs.xml 0000644 0000156 0000165 00000002000 12704153516 016207 0 ustar jenkins jenkins
]>
libhud DocsData TypesObject HierarchyAPI IndexIndex of deprecated API
./docs/libhud/libhud-sections.txt 0000644 0000156 0000165 00000002636 12704153516 017144 0 ustar jenkins jenkins action-publisher
HUD_ACTION_PUBLISHER_SIGNAL_ACTION_GROUP_ADDED
HUD_ACTION_PUBLISHER_SIGNAL_ACTION_GROUP_REMOVED
HudActionDescription
HudActionPublisher
HudActionPublisherActionGroupSet
hud_action_description_get_action_name
hud_action_description_get_action_target
hud_action_description_new
hud_action_description_ref
hud_action_description_set_attribute
hud_action_description_set_attribute_value
hud_action_description_set_parameterized
hud_action_description_unref
hud_action_publisher_add_action_group
hud_action_publisher_add_description
hud_action_publisher_get_action_groups
hud_action_publisher_get_description_path
hud_action_publisher_get_id
hud_action_publisher_new_for_application
hud_action_publisher_new_for_id
hud_action_publisher_remove_action_group
HUD_ACTION_DESCRIPTION
HUD_ACTION_PUBLISHER
HUD_IS_ACTION_DESCRIPTION
HUD_IS_ACTION_PUBLISHER
HUD_TYPE_ACTION_DESCRIPTION
HUD_TYPE_ACTION_PUBLISHER
hud_action_description_get_type
hud_action_publisher_get_type
managerHudManager
HUD_MANAGER_PROP_APPLICATION
HUD_MANAGER_PROP_APP_ID
HudManagerClass
hud_manager_add_actions
hud_manager_new
hud_manager_new_for_application
hud_manager_remove_actions
HUD_IS_MANAGER
HUD_IS_MANAGER_CLASS
HUD_MANAGER
HUD_MANAGER_CLASS
HUD_MANAGER_GET_CLASS
HUD_TYPE_MANAGER
HudManagerPrivate
hud_manager_get_type
./docs/libhud/libhud.types 0000644 0000156 0000165 00000000123 12704153516 015631 0 ustar jenkins jenkins hud_action_description_get_type
hud_action_publisher_get_type
hud_manager_get_type
./docs/libhud/CMakeLists.txt 0000644 0000156 0000165 00000001254 12704153516 016042 0 ustar jenkins jenkins
find_package(GtkDoc)
if(GTKDOC_FOUND)
get_target_property(_hud_output_name hud OUTPUT_NAME)
include(UseGtkDoc)
gtk_doc_add_module(libhud "${CMAKE_SOURCE_DIR}/libhud"
XML
libhud-docs.xml
SUFFIXES
h c
IGNOREHEADERS
hud.h
app-iface.h
marshal.h
service-iface.h
LDFLAGS
-L${CMAKE_CURRENT_BINARY_DIR}/../../libhud
-l${_hud_output_name}
LDPATH
${CMAKE_CURRENT_BINARY_DIR}/../../libhud
DEPENDS
hud
)
install(
DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/libhud/html/"
DESTINATION "${CMAKE_INSTALL_DATADIR}/gtk-doc/html/libhud"
)
else()
message(STATUS "gtkdoc was not found.")
endif()
./docs/libhud-communication.msc 0000644 0000156 0000165 00000000772 12704153516 016655 0 ustar jenkins jenkins msc {
app [label="Application"], libhud [label="libHUD"], hud [label="HUD Service"];
app => libhud [label="Initialize"];
libhud => hud [label="Register Application"];
hud >> libhud [label="Application Object Path"];
---;
app box app [label="Put actions on DBus"];
app => libhud [label="Register actions with HUD"];
app => libhud [label="Add descriptions"];
libhud => hud [label="Add to application"];
hud -> app [label="Introspect Actions"];
hud -> app [label="Introspect Descriptions"];
}
./docs/libhud-client/ 0000755 0000156 0000165 00000000000 12704153516 014554 5 ustar jenkins jenkins ./docs/libhud-client/libhud-client-sections.txt 0000644 0000156 0000165 00000004616 12704153516 021674 0 ustar jenkins jenkins query
HudClientQuery
HudClientQueryClass
hud_client_query_execute_command
hud_client_query_execute_param_command
hud_client_query_execute_toolbar_item
hud_client_query_get_active_toolbar
hud_client_query_get_appstack_model
hud_client_query_get_query
hud_client_query_get_results_model
hud_client_query_new
hud_client_query_new_for_connection
hud_client_query_toolbar_item_active
hud_client_query_set_appstack_app
hud_client_query_set_query
hud_client_query_voice_query
hud_client_query_appstack_get_app_icon
hud_client_query_appstack_get_app_id
hud_client_query_results_get_command_highlights
hud_client_query_results_get_command_id
hud_client_query_results_get_command_name
hud_client_query_results_get_description
hud_client_query_results_get_description_highlights
hud_client_query_results_get_shortcut
hud_client_query_results_is_parameterized
HudClientQueryPrivate
HUD_CLIENT_QUERY
HUD_CLIENT_QUERY_CLASS
HUD_CLIENT_QUERY_GET_CLASS
HUD_CLIENT_QUERY_SIGNAL_MODELS_CHANGED
HUD_CLIENT_QUERY_SIGNAL_TOOLBAR_UPDATED
HUD_CLIENT_TYPE_QUERY
HUD_CLIENT_IS_QUERY
HUD_CLIENT_IS_QUERY_CLASS
hud_client_query_get_type
HUD_CLIENT_TYPE_CLIENT_QUERY_TOOLBAR_ITEMS
HudClientQueryToolbarItems
hud_client_query_toolbar_items_get_nick
hud_client_query_toolbar_items_get_type
hud_client_query_toolbar_items_get_value_from_nick
connection
HudClientConnection
HudClientConnectionClass
hud_client_connection_connected
hud_client_connection_get_address
hud_client_connection_get_ref
hud_client_connection_new
hud_client_connection_new_query
HudClientConnectionPrivate
HUD_CLIENT_CONNECTION
HUD_CLIENT_CONNECTION_CLASS
HUD_CLIENT_CONNECTION_GET_CLASS
HUD_CLIENT_CONNECTION_SIGNAL_CONNECTION_STATUS
HUD_CLIENT_IS_CONNECTION
HUD_CLIENT_IS_CONNECTION_CLASS
HUD_CLIENT_TYPE_CONNECTION
hud_client_connection_get_type
HudClientConnectionNewQueryCallback
param
HudClientParam
HudClientParamClass
hud_client_param_get_actions
hud_client_param_get_model
hud_client_param_new
hud_client_param_send_cancel
hud_client_param_send_commit
hud_client_param_send_reset
HUD_CLIENT_IS_PARAM
HUD_CLIENT_IS_PARAM_CLASS
HUD_CLIENT_PARAM
HUD_CLIENT_PARAM_CLASS
HUD_CLIENT_PARAM_GET_CLASS
HUD_CLIENT_TYPE_PARAM
HudClientParamPrivate
hud_client_param_get_type
HUD_CLIENT_PARAM_SIGNAL_MODEL_READY
./docs/libhud-client/libhud-client-docs.xml 0000644 0000156 0000165 00000002046 12704153516 020751 0 ustar jenkins jenkins
]>
libhud-client DocsData TypesObject HierarchyAPI IndexIndex of deprecated API
./docs/libhud-client/CMakeLists.txt 0000644 0000156 0000165 00000001542 12704153516 017316 0 ustar jenkins jenkins
find_package(GtkDoc)
if(GTKDOC_FOUND)
get_target_property(_hud_client_output_name hud-client OUTPUT_NAME)
include(UseGtkDoc)
gtk_doc_add_module(libhud-client "${CMAKE_SOURCE_DIR}/libhud-client"
XML
libhud-client-docs.xml
SUFFIXES
h c
IGNOREHEADERS
HudClient.h
HudToolbarModel.h
action-muxer.h
connection-private.h
hud-client.h
query-iface.h
service-iface.h
toolbar-items.h
LDFLAGS
-L${CMAKE_CURRENT_BINARY_DIR}/../../libhud-client
-l${_hud_client_output_name}
LDPATH
${CMAKE_CURRENT_BINARY_DIR}/../../libhud-client
DEPENDS
hud-client
)
install(
DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/libhud-client/html/"
DESTINATION "${CMAKE_INSTALL_DATADIR}/gtk-doc/html/libhud-client"
)
else()
message(STATUS "gtkdoc was not found.")
endif()
./docs/libhud-client/libhud-client.types 0000644 0000156 0000165 00000000071 12704153516 020363 0 ustar jenkins jenkins hud_client_query_get_type
hud_client_connection_get_type
./docs/libhud-gtk/ 0000755 0000156 0000165 00000000000 12704153516 014063 5 ustar jenkins jenkins ./docs/libhud-gtk/libhud-gtk.types 0000644 0000156 0000165 00000000031 12704153516 017175 0 ustar jenkins jenkins hud_gtk_manager_get_type
./docs/libhud-gtk/libhud-gtk-sections.txt 0000644 0000156 0000165 00000000522 12704153516 020502 0 ustar jenkins jenkins managerHudGtkManager
HudGtkManagerClass
hud_gtk_manager_get_publisher
hud_gtk_manager_new
HUD_GTK_IS_MANAGER
HUD_GTK_IS_MANAGER_CLASS
HUD_GTK_MANAGER
HUD_GTK_MANAGER_CLASS
HUD_GTK_MANAGER_GET_CLASS
HUD_GTK_TYPE_MANAGER
HudGtkManagerPrivate
hud_gtk_manager_get_type
./docs/libhud-gtk/CMakeLists.txt 0000644 0000156 0000165 00000001234 12704153516 016623 0 ustar jenkins jenkins
find_package(GtkDoc)
if(GTKDOC_FOUND)
get_target_property(_hud_output_name hud-gtk OUTPUT_NAME)
include(UseGtkDoc)
gtk_doc_add_module(libhud-gtk "${CMAKE_SOURCE_DIR}/libhud-gtk"
XML
libhud-gtk-docs.xml
SUFFIXES
h c
IGNOREHEADERS
hud-gtk.h
LDFLAGS
-L${CMAKE_CURRENT_BINARY_DIR}/../../libhud-gtk
-l${_hud_output_name}
LDPATH
${CMAKE_CURRENT_BINARY_DIR}/../../libhud-gtk
DEPENDS
hud-gtk
)
install(
DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/libhud-gtk/html/"
DESTINATION "${CMAKE_INSTALL_DATADIR}/gtk-doc/html/libhud-gtk"
)
else()
message(STATUS "gtkdoc was not found.")
endif()
./docs/libhud-gtk/libhud-gtk-docs.xml 0000644 0000156 0000165 00000001722 12704153516 017567 0 ustar jenkins jenkins
]>
libhud-gtk DocsData TypesObject HierarchyAPI IndexIndex of deprecated API
./docs/libhud-client.msc 0000644 0000156 0000165 00000001030 12704153516 015252 0 ustar jenkins jenkins msc {
shell [label="Unity"], client [label="libhud-client"], hud [label="HUD Service"];
shell => client [label="query_new"];
client => hud [label="CreateQuery"];
client >> shell [label="Query Object"];
hud >> client [label="Query Path"];
client => hud [label="Build Proxy"];
hud -> client [label="Update Models"];
client -> shell [label="Models Ready"];
---;
shell box shell [label="Update Query"];
shell => client [label="Change Query"];
client => hud [label="Change Query"];
hud -> shell [label="Update Models"];
}
./docs/CMakeLists.txt 0000644 0000156 0000165 00000000436 12704153516 014574 0 ustar jenkins jenkins include(UseMscgen)
add_subdirectory(man)
add_subdirectory(libhud)
add_subdirectory(libhud-client)
add_subdirectory(libhud-gtk)
install(
FILES
"HUD Architecture.svg"
DESTINATION
${CMAKE_INSTALL_DOCDIR}
)
mscgen(libhud-communication INSTALL)
mscgen(libhud-client INSTALL)
./service/ 0000755 0000156 0000165 00000000000 12704153526 012542 5 ustar jenkins jenkins ./service/Result.h 0000644 0000156 0000165 00000003405 12704153516 014172 0 ustar jenkins jenkins /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see .
*
* Author: Pete Woods
*/
#ifndef HUD_SERVICE_RESULT_H_
#define HUD_SERVICE_RESULT_H_
#include
#include
#include
namespace hud {
namespace service {
class Result {
public:
typedef QPair Highlight;
typedef QList HighlightList;
explicit Result();
Result(qulonglong id, const QString &commandName,
const HighlightList &commandHighlights, const QString &description,
const HighlightList &descriptionHighlights, const QString &shortcut,
int distance, bool parameterized);
virtual ~Result();
qulonglong id() const;
const QString & commandName() const;
const HighlightList & commandHighlights() const;
const QString & description() const;
const HighlightList & descriptionHighlights() const;
const QString & shortcut() const;
int distance() const;
bool parameterized() const;
protected:
uint64_t m_id;
QString m_commandName;
HighlightList m_commandHighlights;
QString m_description;
HighlightList m_descriptionHighlights;
QString m_shortcut;
int m_distance;
bool m_parameterized;
};
}
}
#endif /* HUD_SERVICE_RESULT_H_ */
./service/SignalHandler.h 0000644 0000156 0000165 00000002545 12704153516 015433 0 ustar jenkins jenkins /*
* Copyright (C) 2014 Canonical, Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see .
*
* Author: Pete Woods
*/
#ifndef HUD_SERVICE_SIGNALHANDLER_H_
#define HUD_SERVICE_SIGNALHANDLER_H_
#include
#include
namespace hud {
namespace service {
class SignalHandler: public QObject {
Q_OBJECT
public:
SignalHandler(QObject *parent = 0);
~SignalHandler() = default;
static int setupUnixSignalHandlers();
protected Q_SLOTS:
void handleSigInt();
void handleSigTerm();
protected:
static void intSignalHandler(int unused);
static void termSignalHandler(int unused);
static int sigintFd[2];
static int sigtermFd[2];
QSocketNotifier *m_socketNotifierInt;
QSocketNotifier *m_socketNotifierTerm;
};
}
}
#endif /* HUD_SERVICE_SIGNALHANDLER_H_ */
./service/SearchSettings.cpp 0000644 0000156 0000165 00000001525 12704153516 016176 0 ustar jenkins jenkins /*
* Copyright (C) 2014 Canonical, Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see .
*
* Author: Pete Woods
*/
#include
using namespace hud::service;
SearchSettings::SearchSettings() {
}
SearchSettings::~SearchSettings() {
}
./service/ApplicationListImpl.h 0000644 0000156 0000165 00000004665 12704153516 016646 0 ustar jenkins jenkins /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see .
*
* Author: Pete Woods
*/
#ifndef HUD_SERVICE_APPLICATIONLISTIMPL_H_
#define HUD_SERVICE_APPLICATIONLISTIMPL_H_
#include
#include
#include
#include
#include
#include
namespace hud {
namespace service {
class Factory;
class ApplicationListImpl: public ApplicationList {
Q_OBJECT
public:
ApplicationListImpl(Factory &factory,
QSharedPointer windowStack,
QSharedPointer windowStackWatcher);
virtual ~ApplicationListImpl();
QList applications() const override;
Application::Ptr focusedApplication() const override;
Window::Ptr focusedWindow() const override;
Application::Ptr ensureApplication(const QString &applicationId) override;
public Q_SLOTS:
void FocusedWindowChanged(uint windowId, const QString &applicationId,
uint stage);
void WindowCreated(uint windowId, const QString &applicationId);
void WindowDestroyed(uint windowId, const QString &applicationId);
protected Q_SLOTS:
void serviceUnregistered(const QString &service);
protected:
void ensureApplicationWithWindow(uint windowId,
const QString& applicationId);
void removeWindow(uint windowId, const QString& applicationId);
void setFocusedWindow(Application::Ptr application, uint windowId);
static bool isIgnoredApplication(const QString &applicationId);
QSharedPointer m_windowStack;
QSharedPointer m_windowStackWatcher;
Factory &m_factory;
QMap m_applications;
Application::Ptr m_focusedApplication;
uint m_focusedWindowId;
};
}
}
#endif /* HUD_SERVICE_APPLICATIONLIST_IMPLH_ */
./service/ApplicationImpl.h 0000644 0000156 0000165 00000005266 12704153516 016010 0 ustar jenkins jenkins /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see .
*
* Author: Pete Woods
*/
#ifndef HUD_SERVICE_APPLICATIONIMPL_H_
#define HUD_SERVICE_APPLICATIONIMPL_H_
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
class ApplicationAdaptor;
namespace hud {
namespace service {
class Factory;
class Q_DECL_EXPORT ApplicationImpl: public Application, protected QDBusContext {
Q_OBJECT
public:
ApplicationImpl(const QString &applicationId, Factory &factory,
const QDBusConnection &connection, QObject *parent = 0);
virtual ~ApplicationImpl();
const QString & id() const override;
void addWindow(unsigned int windowId) override;
void removeWindow(unsigned int windowId) override;
Window::Ptr window(unsigned int windowId) override;
bool isEmpty() const override;
const QDBusObjectPath & path() const override;
Q_PROPERTY(QList ActionGroups READ actionGroups)
QList actionGroups() const;
Q_PROPERTY(QString DesktopPath READ desktopPath)
const QString & desktopPath();
Q_PROPERTY(QString Icon READ icon)
const QString & icon() override;
Q_PROPERTY(QList MenuModels READ menuModels)
QList menuModels() const;
public Q_SLOTS:
void AddSources(const QList &actions,
const QList &descriptions);
void SetWindowContext(uint window, const QString &context);
protected:
WindowContext::Ptr windowContext(unsigned int windowId);
QString messageSender();
QScopedPointer m_adaptor;
QDBusConnection m_connection;
QDBusObjectPath m_path;
QString m_applicationId;
Factory &m_factory;
WindowContext::Ptr m_allWindowsContext;
QMap m_windows;
QString m_desktopPath;
QString m_icon;
};
}
}
#endif /* HUD_SERVICE_APPLICATIONIMPL_H_ */
./service/Voice.cpp 0000644 0000156 0000165 00000001463 12704153516 014316 0 ustar jenkins jenkins /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see .
*
* Author: Marcus Tomlinson
*/
#include
using namespace hud::service;
Voice::Voice() {
}
Voice::~Voice() {
}
./service/WindowContext.cpp 0000644 0000156 0000165 00000001517 12704153516 016065 0 ustar jenkins jenkins /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see .
*
* Author: Pete Woods
*/
#include
using namespace hud::service;
WindowContext::WindowContext() {
}
WindowContext::~WindowContext() {
}
./service/SqliteUsageTracker.h 0000644 0000156 0000165 00000003065 12704153516 016460 0 ustar jenkins jenkins /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see .
*
* Author: Pete Woods
*/
#ifndef HUD_SERVICE_SQLITEUSAGETRACKER_H_
#define HUD_SERVICE_SQLITEUSAGETRACKER_H_
#include
#include
#include
#include
#include
namespace hud {
namespace service {
class SqliteUsageTracker: public UsageTracker {
Q_OBJECT
public:
SqliteUsageTracker();
virtual ~SqliteUsageTracker();
void markUsage(const QString &applicationId, const QString &entry) override;
unsigned int usage(const QString &applicationId, const QString &entry) const
override;
protected Q_SLOTS:
void loadFromDatabase();
protected:
typedef QPair UsagePair;
QMap m_usage;
QTimer m_timer;
QSqlDatabase m_db;
QScopedPointer m_insert;
QScopedPointer m_query;
QScopedPointer m_delete;
};
}
}
#endif /* HUD_SERVICE_SQLITEUSAGETRACKER_H_ */
./service/ItemStore.cpp 0000644 0000156 0000165 00000023414 12704153526 015165 0 ustar jenkins jenkins /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see .
*
* Author: Pete Woods
*/
#include
#include
#include
#include
#include
#include
#include
using namespace hud::service;
using namespace Columbus;
static const QRegularExpression SINGLE_AMPERSAND("(?addPenalty());
errorValues.setDeletionError(m_settings->dropPenalty());
errorValues.setEndDeletionError(m_settings->endDropPenalty());
errorValues.setTransposeError(m_settings->swapPenalty());
}
static QString convertActionText(const QAction *action) {
return action->text().remove(SINGLE_AMPERSAND).replace("&&", "&");
}
static QChar getMnemonic(const QAction *action) {
int ampersandIndex = action->text().indexOf(SINGLE_AMPERSAND);
if (ampersandIndex < 0 || ampersandIndex >= action->text().length() - 1) {
return 0;
}
return action->text()[ampersandIndex+1].toLower();
}
void ItemStore::indexMenu(const QMenu *menu, const QMenu *root,
const QStringList &stack, const QList &index) {
int i(-1);
for (QAction *action : menu->actions()) {
++i;
if (!action->isEnabled()) {
continue;
}
if (action->isSeparator()) {
continue;
}
bool searchByMnemonic(action->property("searchByMnemonic").toBool());
QStringList text(
convertActionText(action).remove(BAD_CHARACTERS).split(
WHITESPACE));
bool isParameterized(action->property("isParameterized").toBool());
// We don't descend into parameterized actions
QMenu *child(action->menu());
if (!isParameterized && child) {
QStringList childStack(stack);
childStack << text;
QList childIndex(index);
childIndex << i;
indexMenu(child, root, childStack, childIndex);
} else {
Document document(m_nextId);
if (searchByMnemonic) {
QChar mnemonic = getMnemonic(action);
m_mnemonic2DocumentId[mnemonic] = m_nextId;
}
WordList command;
for (const QString &word : text) {
command.addWord(Word(word.toUtf8().constData()));
}
document.addText(Word("command"), command);
WordList wordList;
QVariant keywords(action->property("keywords"));
QStringList context;
if (!keywords.isNull()) {
context = keywords.toString().split(WHITESPACE_OR_SEMICOLON);
} else {
context = stack;
}
for (const QString &word : context) {
wordList.addWord(Word(word.toUtf8().constData()));
}
document.addText(Word("context"), wordList);
m_corpus.addDocument(document);
Item::Ptr item(new Item(root, index, i));
m_items[m_nextId] = item;
QVariant toolbarItem(action->property("hud-toolbar-item"));
if (!toolbarItem.isNull()) {
m_toolbarItems[toolbarItem.toString()] = item;
}
++m_nextId;
}
}
}
void ItemStore::indexMenu(const QMenu *menu) {
if (menu == nullptr) {
return;
}
indexMenu(menu, menu, QStringList(), QList());
m_matcher.index(m_corpus);
}
static void findHighlights(Result::HighlightList &highlights,
const QStringMatcher &matcher, int length, const QString &s) {
if (length > 0) {
int idx = matcher.indexIn(s);
while (idx != -1) {
highlights << Result::Highlight(idx, idx + length);
idx = matcher.indexIn(s, idx + length);
}
}
}
static QString convertToEntry(Item::Ptr item, const QAction *action) {
QString result;
for (const QAction *context : item->context()) {
result.append(convertActionText(context));
result.append("||");
}
result.append(convertActionText(action));
return result;
}
void ItemStore::search(const QString &query,
Query::EmptyBehaviour emptyBehaviour, QList &results) {
QStringMatcher stringMatcher(query, Qt::CaseInsensitive);
if (query.isEmpty()) {
if (emptyBehaviour == Query::EmptyBehaviour::NO_SUGGESTIONS) {
return;
}
QMap tempResults;
for (auto it(m_items.constBegin()); it != m_items.constEnd(); ++it) {
const QAction* action = it.value()->action();
if (action) {
tempResults.insertMulti(
m_usageTracker->usage(m_applicationId,
convertToEntry(it.value(), action)), it.key());
}
}
int maxResults = std::min(m_items.size(), 20);
int count = 0;
QMapIterator it(tempResults);
it.toBack();
while (count < maxResults && it.hasPrevious()) {
it.previous();
addResult(it.value(), stringMatcher, 0, 0, results);
++count;
}
} else {
QString cleanQuery(query);
cleanQuery.remove(BAD_CHARACTERS);
WordList queryList;
for (const QString &word : cleanQuery.split(WHITESPACE)) {
queryList.addWord(Word(word.toUtf8().constData()));
}
try {
MatchResults matchResults(
m_matcher.onlineMatch(queryList, Word("command")));
int queryLength(query.length());
if (queryLength == 1 && m_mnemonic2DocumentId.contains(query[0])) {
int docId = m_mnemonic2DocumentId[query[0]];
addResult(docId, stringMatcher, queryLength, 1.0, results);
}
size_t maxResults = std::min(matchResults.size(), size_t(20));
for (size_t i(0); i < maxResults; ++i) {
DocumentID id(matchResults.getDocumentID(i));
double relevancy(matchResults.getRelevancy(i));
addResult(id, stringMatcher, queryLength, relevancy, results);
}
} catch (std::invalid_argument &e) {
}
}
}
void ItemStore::addResult(DocumentID id, const QStringMatcher &stringMatcher,
const int queryLength, const double relevancy, QList &results) {
Item::Ptr item(m_items[id]);
const QAction *action(item->action());
if (!action) {
return;
}
QString commandName(convertActionText(action));
Result::HighlightList commandHighlights;
findHighlights(commandHighlights, stringMatcher, queryLength, commandName);
QString description;
QVariant keywords(action->property("keywords"));
if (!keywords.isNull()) {
description = keywords.toString().replace(";", _(", "));
} else {
bool first(true);
for (const QAction *a : item->context()) {
if (first) {
first = false;
} else {
description.append(_(", "));
}
description.append(convertActionText(a));
}
}
Result::HighlightList descriptionHighlights;
findHighlights(descriptionHighlights, stringMatcher, queryLength,
description);
bool isParameterized(action->property("isParameterized").toBool());
results
<< Result(id, commandName, commandHighlights, description,
descriptionHighlights, action->shortcut().toString(),
relevancy * 100, isParameterized);
}
void ItemStore::executeItem(Item::Ptr item) {
if (item.isNull()) {
qWarning() << "Tried to execute unknown command";
return;
}
QAction *action(item->action());
if (action == nullptr) {
qWarning() << "Tried to execute unknown command";
return;
}
action->activate(QAction::ActionEvent::Trigger);
m_usageTracker->markUsage(m_applicationId, convertToEntry(item, action));
}
void ItemStore::execute(unsigned long long int commandId) {
Item::Ptr item(m_items[commandId]);
executeItem(item);
}
QString ItemStore::executeParameterized(unsigned long long commandId,
QString &prefix, QString &baseAction, QDBusObjectPath &actionPath,
QDBusObjectPath &modelPath) {
Item::Ptr item(m_items[commandId]);
if (item.isNull()) {
qWarning() << "Tried to execute unknown parameterized command"
<< commandId;
return QString();
}
QAction *action(item->action());
if (action == nullptr) {
qWarning() << "Tried to execute unknown parameterized command"
<< commandId;
return QString();
}
QString name = action->property("actionName").toString();
int index = name.indexOf( '.' );
if (index == -1) {
baseAction = name;
} else {
prefix = name.left(index);
baseAction = name.right(name.size() - index - 1);
}
actionPath = QDBusObjectPath(action->property("actionsPath").toString());
modelPath = QDBusObjectPath(action->property("menuPath").toString());
m_usageTracker->markUsage(m_applicationId, convertToEntry(item, action));
return action->property("busName").toString();
}
void ItemStore::executeToolbar(const QString &name) {
executeItem(m_toolbarItems[name]);
}
QList ItemStore::commands() const {
QList commandsList;
for (uint i = 0; i < m_corpus.size(); ++i) {
QStringList command;
const WordList& words = m_corpus.getDocument(i).getText(
Word("command"));
for (uint j = 0; j < words.size(); ++j) {
command.append(words[j].asUtf8().c_str());
}
commandsList.append(command);
}
return commandsList;
}
QStringList ItemStore::toolbarItems() const {
return m_toolbarItems.keys();
}
./service/main.cpp 0000644 0000156 0000165 00000002526 12704153516 014176 0 ustar jenkins jenkins /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see .
*
* Author: Pete Woods
*/
#include
#include
#include
#include
#include
using namespace std;
using namespace hud::service;
int main(int argc, char *argv[]) {
qputenv("QT_QPA_PLATFORM", "minimal");
QApplication application(argc, argv);
setlocale(LC_ALL, "");
bindtextdomain(GETTEXT_PACKAGE, GNOMELOCALEDIR);
textdomain(GETTEXT_PACKAGE);
try {
Factory factory;
factory.singletonHudService();
SignalHandler handler;
handler.setupUnixSignalHandlers();
return application.exec();
} catch (std::exception &e) {
qWarning() << _("Hud Service:") << e.what();
return 1;
}
}
./service/Query.h 0000644 0000156 0000165 00000003576 12704153516 014032 0 ustar jenkins jenkins /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see .
*
* Author: Pete Woods
*/
#ifndef HUD_SERVICE_QUERY_H_
#define HUD_SERVICE_QUERY_H_
#include
#include
#include
#include
#include
#include
class QueryAdaptor;
namespace hud {
namespace service {
class HudService;
class Q_DECL_EXPORT Query: public QObject {
Q_OBJECT
public:
typedef QSharedPointer Ptr;
enum class EmptyBehaviour {
SHOW_SUGGESTIONS,
NO_SUGGESTIONS,
};
explicit Query(QObject *parent = 0);
virtual ~Query();
Q_PROPERTY(QString AppstackModel READ appstackModel)
virtual QString appstackModel() const = 0;
Q_PROPERTY(QString CurrentQuery READ currentQuery)
virtual QString currentQuery() const = 0;
Q_PROPERTY(QString ResultsModel READ resultsModel)
virtual QString resultsModel() const = 0;
Q_PROPERTY(QStringList ToolbarItems READ toolbarItems)
virtual QStringList toolbarItems() const = 0;
virtual const QDBusObjectPath & path() const = 0;
virtual const QList & results() const = 0;
public Q_SLOTS:
virtual int UpdateQuery(const QString &query) = 0;
virtual void ExecuteCommand(const QDBusVariant &item, uint timestamp) = 0;
};
}
}
#endif /* HUD_SERVICE_QUERY_H_ */
./service/DBusMenuWindowCollector.cpp 0000644 0000156 0000165 00000007522 12704153526 017775 0 ustar jenkins jenkins /*
* Copyright (C) 2016 Canonical, Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see .
*
* Author: Andrea Azzarone
*/
#include
#include
#include
#include
#include
#include
using namespace hud::common;
using namespace hud::service;
DBusMenuWindowCollector::DBusMenuWindowCollector(unsigned int windowId,
QSharedPointer windowStack,
QSharedPointer registrar,
Factory &factory) :
m_windowId(windowId), m_registrar(registrar), m_factory(factory) {
connect(registrar.data(),
SIGNAL(WindowRegistered(uint, const QString &, const QDBusObjectPath &)),
this,
SLOT(WindowRegistered(uint, const QString &, const QDBusObjectPath &)));
QDBusPendingReply windowDBusAddressReply(
windowStack->GetWindowBusAddress(windowId));
// Window action menu
windowDBusAddressReply.waitForFinished();
if (!windowDBusAddressReply.isError()) {
QStringList windowDBusAddress(windowDBusAddressReply);
if (windowDBusAddress.size() == 2) {
const QString &name = windowDBusAddress.at(0);
const QString &path = windowDBusAddress.at(1);
if (!name.isEmpty() && !path.isEmpty())
m_am_collector = factory.newDBusMenuCollector(name, QDBusObjectPath(path));
}
}
// AppMenu
QDBusPendingReply windowReply =
registrar->GetMenuForWindow(m_windowId);
windowReply.waitForFinished();
if (windowReply.isError()) {
return;
}
windowRegistered(windowReply.argumentAt<0>(), windowReply.argumentAt<1>());
}
DBusMenuWindowCollector::~DBusMenuWindowCollector() {
}
bool DBusMenuWindowCollector::isValid() const {
return m_collector || m_am_collector;
}
static void setPropertyForAllActions(QMenu *menu) {
if (!menu)
return;
for (QAction *action : menu->actions()) {
if (!action->isEnabled()) {
continue;
}
if (action->isSeparator()) {
continue;
}
action->setProperty("searchByMnemonic", true);
setPropertyForAllActions(action->menu());
}
}
QList DBusMenuWindowCollector::activate() {
QList ret;
if (m_am_collector) {
QList tokens = m_am_collector->activate();
for (CollectorToken::Ptr token : tokens) {
setPropertyForAllActions(token->menu());
}
ret.append(tokens);
}
if (m_collector) {
ret.append(m_collector->activate());
}
return ret;
}
void DBusMenuWindowCollector::deactivate() {
}
void DBusMenuWindowCollector::WindowRegistered(uint windowId, const QString &service,
const QDBusObjectPath &menuObjectPath) {
// Simply ignore updates for other windows
if (windowId != m_windowId) {
return;
}
windowRegistered(service, menuObjectPath);
}
void DBusMenuWindowCollector::windowRegistered(const QString &service,
const QDBusObjectPath &menuObjectPath) {
if (service.isEmpty()) {
return;
}
disconnect(m_registrar.data(),
SIGNAL(WindowRegistered(uint, const QString &, const QDBusObjectPath &)),
this,
SLOT(WindowRegistered(uint, const QString &, const QDBusObjectPath &)));
m_collector = m_factory.newDBusMenuCollector(service, menuObjectPath);
}
./service/Factory.h 0000644 0000156 0000165 00000007247 12704153526 014334 0 ustar jenkins jenkins /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see .
*
* Author: Pete Woods
*/
#ifndef HUD_SERVICE_FACTORY_H_
#define HUD_SERVICE_FACTORY_H_
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
class ComCanonicalUnityWindowStackInterface;
class ComCanonicalAppMenuRegistrarInterface;
QT_BEGIN_NAMESPACE
class QDBusServiceWatcher;
QT_END_NAMESPACE
namespace hud {
namespace service {
class Factory {
public:
explicit Factory();
virtual ~Factory();
void setSessionBus(const QDBusConnection &sessionBus);
virtual HudService::Ptr singletonHudService();
virtual QDBusConnection sessionBus();
virtual QSharedPointer gSessionBus();
virtual QSharedPointer singletonWindowStack();
virtual QSharedPointer windowStackWatcher();
virtual QSharedPointer singletonAppmenu();
virtual Query::Ptr newQuery(const QString &query, const QString &sender,
Query::EmptyBehaviour emptyBehaviour);
virtual ApplicationList::Ptr singletonApplicationList();
virtual UsageTracker::Ptr singletonUsageTracker();
virtual SearchSettings::Ptr singletonSearchSettings();
virtual Voice::Ptr singletonVoice();
virtual Application::Ptr newApplication(const QString &applicationId);
virtual ItemStore::Ptr newItemStore(const QString &applicationId);
virtual Window::Ptr newWindow(unsigned int windowId,
const QString &applicationId, WindowContext::Ptr allwindowsContext);
virtual WindowContext::Ptr newWindowContext();
virtual WindowToken::Ptr newWindowToken(const QString &applicationId,
QList tokens);
virtual Collector::Ptr newDBusMenuCollector(const QString &service,
const QDBusObjectPath &menuObjectPath);
virtual Collector::Ptr newGMenuCollector(const QString &name,
const QMap &actions,
const QDBusObjectPath &menuPath);
QSharedPointer newQtGMenuImporter(
const QString& service, const QDBusObjectPath& menu_path,
const QMap& action_paths);
virtual Collector::Ptr newGMenuWindowCollector(unsigned int windowId,
const QString &applicationId);
virtual Collector::Ptr newDBusMenuWindowCollector(unsigned int windowId);
protected:
QDBusConnection m_sessionBus;
unsigned int m_queryCounter;
HudService::Ptr m_hudService;
ApplicationList::Ptr m_applicationList;
UsageTracker::Ptr m_usageTracker;
SearchSettings::Ptr m_searchSettings;
Voice::Ptr m_voice;
QSharedPointer m_windowStack;
QSharedPointer m_appmenu;
};
}
}
#endif /* HUD_SERVICE_FACTORY_H_ */
./service/ApplicationList.cpp 0000644 0000156 0000165 00000001531 12704153516 016344 0 ustar jenkins jenkins /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see .
*
* Author: Pete Woods
*/
#include
using namespace hud::service;
ApplicationList::ApplicationList() {
}
ApplicationList::~ApplicationList() {
}
./service/GMenuWindowCollector.h 0000644 0000156 0000165 00000003235 12704153516 016767 0 ustar jenkins jenkins /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see .
*
* Author: Pete Woods
*/
#ifndef HUD_SERVICE_GMENUWINDOWCOLLECTOR_H_
#define HUD_SERVICE_GMENUWINDOWCOLLECTOR_H_
#include
#include
class ComCanonicalUnityWindowStackInterface;
namespace qtgmenu {
class QtGMenuImporter;
}
namespace hud {
namespace service {
class Factory;
class GMenuWindowCollector: public Collector,
public std::enable_shared_from_this {
public:
typedef std::shared_ptr Ptr;
GMenuWindowCollector(unsigned int windowId, const QString &applicationId,
QSharedPointer windowStack,
Factory &factory);
virtual ~GMenuWindowCollector();
virtual bool isValid() const override;
virtual QList activate() override;
protected:
virtual void deactivate();
QSharedPointer m_windowStack;
QString m_busName;
QList m_collectors;
};
}
}
#endif /* HUD_SERVICE_GMENUWINDOWCOLLECTOR_H_ */
./service/DBusMenuCollector.h 0000644 0000156 0000165 00000003324 12704153526 016246 0 ustar jenkins jenkins /*
* Copyright (C) 2013-2016 Canonical, Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see .
*
* Author: Pete Woods
* Andrea Azzarone
*/
#ifndef HUD_SERVICE_DBUSMENUCOLLECTOR_H_
#define HUD_SERVICE_DBUSMENUCOLLECTOR_H_
#include
#include
class DBusMenuImporter;
QT_BEGIN_NAMESPACE
class QMenu;
QT_END_NAMESPACE
namespace hud {
namespace service {
class DBusMenuCollector: public Collector,
public std::enable_shared_from_this {
public:
typedef std::shared_ptr Ptr;
DBusMenuCollector(const QString &service, const QDBusObjectPath &menuObjectPath);
virtual ~DBusMenuCollector();
virtual bool isValid() const override;
virtual QList activate() override;
protected:
virtual void deactivate() override;
void openMenu(QMenu *menu, unsigned int &limit);
void hideMenu(QMenu *menu, unsigned int &limit);
QWeakPointer m_collectorToken;
QSharedPointer m_menuImporter;
QString m_service;
QDBusObjectPath m_path;
};
}
}
#endif /* HUD_SERVICE_DBUSMENUCOLLECTOR_H_ */
./service/WindowImpl.h 0000644 0000156 0000165 00000004661 12704153516 015012 0 ustar jenkins jenkins /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see .
*
* Author: Pete Woods
*/
#ifndef HUD_SERVICE_WINDOWIMPL_H_
#define HUD_SERVICE_WINDOWIMPL_H_
#include
#include
#include
#include
#include
#include
#include
namespace hud {
namespace service {
class Factory;
class WindowImpl;
class Q_DECL_EXPORT WindowTokenImpl: public WindowToken {
Q_OBJECT
friend WindowImpl;
public:
WindowTokenImpl(const QList &tokens, ItemStore::Ptr itemStore);
virtual ~WindowTokenImpl();
void search(const QString &query, Query::EmptyBehaviour emptyBehaviour,
QList &results) override;
void execute(unsigned long long commandId) override;
QString executeParameterized(unsigned long long commandId, QString &prefix,
QString &baseAction, QDBusObjectPath &actionPath,
QDBusObjectPath &modelPath) override;
void executeToolbar(const QString &item) override;
QList commands() const override;
QStringList toolbarItems() const override;
const QList & tokens() const override;
protected Q_SLOTS:
void childChanged();
protected:
ItemStore::Ptr m_items;
QList m_tokens;
QTimer m_timer;
};
class WindowImpl: public WindowContextImpl, public Window {
friend WindowTokenImpl;
public:
WindowImpl(unsigned int windowId, const QString &applicationId,
WindowContext::Ptr allWindowsContext, Factory &factory);
virtual ~WindowImpl();
virtual WindowToken::Ptr activate();
protected:
QString m_applicationId;
WindowContext::Ptr m_allWindowsContext;
Collector::Ptr m_dbusMenuCollector;
Collector::Ptr m_gMenuCollector;
QWeakPointer m_windowToken;
};
}
}
#endif /* HUD_SERVICE_WINDOWIMPL_H_ */
./service/SignalHandler.cpp 0000644 0000156 0000165 00000005164 12704153516 015766 0 ustar jenkins jenkins /*
* Copyright (C) 2014 Canonical, Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see .
*
* Author: Pete Woods
*/
#include
#include
#include
#include
#include
#include
using namespace hud::service;
int SignalHandler::sigintFd[2];
int SignalHandler::sigtermFd[2];
SignalHandler::SignalHandler(QObject *parent) :
QObject(parent) {
if (::socketpair(AF_UNIX, SOCK_STREAM, 0, sigintFd)) {
qFatal("Couldn't create INT socketpair");
}
if (::socketpair(AF_UNIX, SOCK_STREAM, 0, sigtermFd)) {
qFatal("Couldn't create TERM socketpair");
}
m_socketNotifierInt = new QSocketNotifier(sigintFd[1], QSocketNotifier::Read, this);
connect(m_socketNotifierInt, &QSocketNotifier::activated, this, &SignalHandler::handleSigInt);
m_socketNotifierTerm = new QSocketNotifier(sigtermFd[1], QSocketNotifier::Read, this);
connect(m_socketNotifierTerm, &QSocketNotifier::activated, this, &SignalHandler::handleSigTerm);
}
void SignalHandler::intSignalHandler(int) {
char a = 1;
::write(sigintFd[0], &a, sizeof(a));
}
void SignalHandler::termSignalHandler(int) {
char a = 1;
::write(sigtermFd[0], &a, sizeof(a));
}
int SignalHandler::setupUnixSignalHandlers() {
struct sigaction sigint, sigterm;
sigint.sa_handler = SignalHandler::intSignalHandler;
sigemptyset(&sigint.sa_mask);
sigint.sa_flags = 0;
sigint.sa_flags |= SA_RESTART;
if (sigaction(SIGINT, &sigint, 0) > 0)
return 1;
sigterm.sa_handler = SignalHandler::termSignalHandler;
sigemptyset(&sigterm.sa_mask);
sigterm.sa_flags |= SA_RESTART;
if (sigaction(SIGTERM, &sigterm, 0) > 0)
return 2;
return 0;
}
void SignalHandler::handleSigTerm() {
m_socketNotifierTerm->setEnabled(false);
char tmp;
::read(sigtermFd[1], &tmp, sizeof(tmp));
QCoreApplication::exit(0);
m_socketNotifierTerm->setEnabled(true);
}
void SignalHandler::handleSigInt() {
m_socketNotifierInt->setEnabled(false);
char tmp;
::read(sigintFd[1], &tmp, sizeof(tmp));
QCoreApplication::exit(0);
m_socketNotifierInt->setEnabled(true);
}
./service/HudService.h 0000644 0000156 0000165 00000002264 12704153516 014757 0 ustar jenkins jenkins /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see .
*
* Author: Pete Woods
*/
#ifndef HUD_SERVICE_SERVICE_H_
#define HUD_SERVICE_SERVICE_H_
#include
#include
#include
class HudAdaptor;
namespace hud {
namespace service {
class Factory;
class Q_DECL_EXPORT HudService: public QObject {
public:
typedef QSharedPointer Ptr;
explicit HudService(QObject *parent = 0);
virtual ~HudService();
virtual Query::Ptr closeQuery(const QDBusObjectPath &path) = 0;
};
}
}
#endif /* HUD_SERVICE_SERVICE_H_ */
./service/WindowContextImpl.cpp 0000644 0000156 0000165 00000003123 12704153516 016702 0 ustar jenkins jenkins /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see .
*
* Author: Pete Woods
*/
#include
#include
#include
#include
using namespace hud::service;
using namespace qtgmenu;
WindowContextImpl::WindowContextImpl(Factory &factory) :
m_factory(factory) {
}
WindowContextImpl::~WindowContextImpl() {
}
void WindowContextImpl::setContext(const QString &context) {
if (m_context == context) {
return;
}
m_context = context;
m_activeCollector = m_collectors[context];
contextChanged();
}
void WindowContextImpl::addMenu(const QString &context,
const MenuDefinition &menuDefinition) {
QMap actions;
actions[menuDefinition.actionPrefix] = menuDefinition.actionPath;
m_collectors[context] = m_factory.newGMenuCollector(menuDefinition.name,
actions, menuDefinition.menuPath);
}
Collector::Ptr WindowContextImpl::activeCollector() {
return m_activeCollector;
}
./service/Window.h 0000644 0000156 0000165 00000003544 12704153516 014167 0 ustar jenkins jenkins /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see .
*
* Author: Pete Woods
*/
#ifndef HUD_SERVICE_WINDOW_H_
#define HUD_SERVICE_WINDOW_H_
#include
#include
#include
#include
namespace hud {
namespace service {
class WindowToken: public QObject {
Q_OBJECT
public:
typedef QSharedPointer Ptr;
virtual ~WindowToken();
virtual void search(const QString &query,
Query::EmptyBehaviour emptyBehaviour, QList &results) = 0;
virtual void execute(unsigned long long commandId) = 0;
virtual QString executeParameterized(unsigned long long commandId,
QString &prefix, QString &baseAction, QDBusObjectPath &actionPath,
QDBusObjectPath &modelPath) = 0;
virtual void executeToolbar(const QString &item) = 0;
virtual QList commands() const = 0;
virtual QStringList toolbarItems() const = 0;
virtual const QList & tokens() const = 0;
Q_SIGNALS:
void changed();
protected:
explicit WindowToken();
};
class Window: public virtual WindowContext {
public:
typedef QSharedPointer Ptr;
explicit Window();
virtual ~Window();
virtual WindowToken::Ptr activate() = 0;
};
}
}
#endif /* HUD_SERVICE_WINDOW_H_ */
./service/WindowContext.h 0000644 0000156 0000165 00000003512 12704153516 015527 0 ustar jenkins jenkins /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see .
*
* Author: Pete Woods
*/
#ifndef HUD_SERVICE_WINDOWCONTEXT_H_
#define HUD_SERVICE_WINDOWCONTEXT_H_
#include
#include
#include
#include
#include
namespace qtgmenu {
class QtGMenuImporter;
}
namespace hud {
namespace service {
class WindowContext: public QObject {
Q_OBJECT
public:
struct MenuDefinition {
explicit MenuDefinition() {
}
explicit MenuDefinition(const QString &name) :
name(name) {
}
bool operator==(const MenuDefinition &other) const {
return name == other.name && actionPath == other.actionPath
&& actionPrefix == other.actionPrefix
&& menuPath == other.menuPath;
}
QString name;
QDBusObjectPath actionPath;
QString actionPrefix;
QDBusObjectPath menuPath;
};
typedef QSharedPointer Ptr;
explicit WindowContext();
virtual ~WindowContext();
virtual void setContext(const QString &context) = 0;
virtual void addMenu(const QString &context,
const MenuDefinition &menuDefinition) = 0;
virtual Collector::Ptr activeCollector() = 0;
Q_SIGNALS:
void contextChanged();
};
}
}
#endif /* HUD_SERVICE_WINDOWCONTEXT_H_ */
./service/Factory.cpp 0000644 0000156 0000165 00000013744 12704153526 014666 0 ustar jenkins jenkins /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY{} without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see .
*
* Author: Pete Woods
*/
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
using namespace hud::common;
using namespace hud::service;
Factory::Factory() :
m_sessionBus(QDBusConnection::sessionBus()), m_queryCounter(0) {
DBusTypes::registerMetaTypes();
}
Factory::~Factory() {
}
void Factory::setSessionBus(const QDBusConnection &sessionBus) {
m_sessionBus = sessionBus;
}
HudService::Ptr Factory::singletonHudService() {
if (m_hudService.isNull()) {
m_hudService.reset(
new HudServiceImpl(*this, singletonApplicationList(),
sessionBus()));
}
return m_hudService;
}
QSharedPointer Factory::singletonWindowStack() {
if (m_windowStack.isNull()) {
m_windowStack.reset(
new ComCanonicalUnityWindowStackInterface(
DBusTypes::WINDOW_STACK_DBUS_NAME,
DBusTypes::WINDOW_STACK_DBUS_PATH, sessionBus()));
}
return m_windowStack;
}
QSharedPointer Factory::windowStackWatcher() {
return QSharedPointer(
new QDBusServiceWatcher(DBusTypes::WINDOW_STACK_DBUS_NAME,
sessionBus(), QDBusServiceWatcher::WatchForUnregistration));
}
QSharedPointer Factory::singletonAppmenu() {
if (m_appmenu.isNull()) {
m_appmenu.reset(
new ComCanonicalAppMenuRegistrarInterface(
DBusTypes::APPMENU_REGISTRAR_DBUS_NAME,
DBusTypes::APPMENU_REGISTRAR_DBUS_PATH, sessionBus()));
}
return m_appmenu;
}
QDBusConnection Factory::sessionBus() {
return m_sessionBus;
}
QSharedPointer Factory::gSessionBus() {
return QSharedPointer(g_bus_get_sync(G_BUS_TYPE_SESSION, nullptr, nullptr), &g_object_unref);
}
Query::Ptr Factory::newQuery(const QString &query, const QString &sender,
Query::EmptyBehaviour emptyBehaviour) {
return Query::Ptr(
new QueryImpl(m_queryCounter++, query, sender, emptyBehaviour,
*singletonHudService(), singletonApplicationList(),
singletonVoice(), sessionBus()));
}
ApplicationList::Ptr Factory::singletonApplicationList() {
if (m_applicationList.isNull()) {
m_applicationList.reset(
new ApplicationListImpl(*this, singletonWindowStack(),
windowStackWatcher()));
}
return m_applicationList;
}
UsageTracker::Ptr Factory::singletonUsageTracker() {
if (m_usageTracker.isNull()) {
m_usageTracker.reset(new SqliteUsageTracker());
}
return m_usageTracker;
}
SearchSettings::Ptr Factory::singletonSearchSettings() {
if (m_searchSettings.isNull()) {
if (qEnvironmentVariableIsSet("HUD_IGNORE_SEARCH_SETTINGS")) {
m_searchSettings.reset(new HardCodedSearchSettings());
} else {
m_searchSettings.reset(new QGSettingsSearchSettings());
}
}
return m_searchSettings;
}
Voice::Ptr Factory::singletonVoice() {
if (m_voice.isNull()) {
m_voice.reset(new VoiceImpl());
}
return m_voice;
}
Application::Ptr Factory::newApplication(const QString &applicationId) {
return Application::Ptr(
new ApplicationImpl(applicationId, *this, sessionBus()));
}
ItemStore::Ptr Factory::newItemStore(const QString &applicationId) {
return ItemStore::Ptr(
new ItemStore(applicationId, singletonUsageTracker(),
singletonSearchSettings()));
}
Window::Ptr Factory::newWindow(unsigned int windowId,
const QString &applicationId, WindowContext::Ptr allwindowsContext) {
return Window::Ptr(
new WindowImpl(windowId, applicationId, allwindowsContext, *this));
}
WindowToken::Ptr Factory::newWindowToken(const QString &applicationId,
QList tokens) {
return WindowToken::Ptr(new WindowTokenImpl(tokens, newItemStore(applicationId)));
}
WindowContext::Ptr Factory::newWindowContext() {
return WindowContext::Ptr(new WindowContextImpl(*this));
}
Collector::Ptr Factory::newDBusMenuCollector(const QString &service,
const QDBusObjectPath &menuObjectPath) {
return Collector::Ptr(new DBusMenuCollector(service, menuObjectPath));
}
Collector::Ptr Factory::newGMenuCollector(const QString &name,
const QMap &actions,
const QDBusObjectPath &menuPath) {
return Collector::Ptr(new GMenuCollector(name, actions, menuPath, *this));
}
QSharedPointer Factory::newQtGMenuImporter(
const QString& service, const QDBusObjectPath& menu_path,
const QMap& action_paths) {
return QSharedPointer(
new qtgmenu::QtGMenuImporter(service, menu_path, action_paths,
sessionBus(), gSessionBus()));
}
Collector::Ptr Factory::newGMenuWindowCollector(unsigned int windowId,
const QString &applicationId) {
return Collector::Ptr(
new GMenuWindowCollector(windowId, applicationId,
singletonWindowStack(), *this));
}
Collector::Ptr Factory::newDBusMenuWindowCollector(unsigned int windowId) {
return Collector::Ptr(
new DBusMenuWindowCollector(windowId,
singletonWindowStack(), singletonAppmenu(), *this));
}
./service/ApplicationImpl.cpp 0000644 0000156 0000165 00000012401 12704153516 016330 0 ustar jenkins jenkins /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see .
*
* Author: Pete Woods
*/
#include
#include
#include
#include
#include
using namespace hud::common;
using namespace hud::service;
ApplicationImpl::ApplicationImpl(const QString &applicationId, Factory &factory,
const QDBusConnection &connection, QObject *parent) :
Application(parent), m_adaptor(new ApplicationAdaptor(this)), m_connection(
connection), m_path(DBusTypes::applicationPath(applicationId)), m_applicationId(
applicationId), m_factory(factory) {
if (!m_connection.registerObject(m_path.path(), this)) {
throw std::logic_error(_("Unable to register HUD object on DBus"));
}
m_allWindowsContext = m_factory.newWindowContext();
}
ApplicationImpl::~ApplicationImpl() {
m_connection.unregisterObject(m_path.path());
}
const QString & ApplicationImpl::id() const {
return m_applicationId;
}
void ApplicationImpl::addWindow(unsigned int windowId) {
if (m_windows.contains(windowId)) {
qWarning() << "Adding already known window" << windowId
<< "to application" << m_applicationId;
return;
}
m_windows[windowId] = m_factory.newWindow(windowId, m_applicationId,
m_allWindowsContext);
}
void ApplicationImpl::removeWindow(unsigned int windowId) {
if (!m_windows.contains(windowId)) {
qWarning() << "Removing unknown window" << windowId
<< "from application" << m_applicationId;
return;
}
m_windows.remove(windowId);
}
Window::Ptr ApplicationImpl::window(unsigned int windowId) {
return m_windows[windowId];
}
WindowContext::Ptr ApplicationImpl::windowContext(unsigned int windowId) {
if (windowId == WINDOW_ID_ALL_WINDOWS) {
return m_allWindowsContext;
}
return m_windows[windowId];
}
bool ApplicationImpl::isEmpty() const {
return m_windows.isEmpty();
}
const QDBusObjectPath & ApplicationImpl::path() const {
return m_path;
}
const QString & ApplicationImpl::desktopPath() {
if (m_desktopPath.isEmpty()) {
QString desktopFile(QString("%1.desktop").arg(m_applicationId));
QStringList xdgDataDirs(
QString::fromUtf8(qgetenv("XDG_DATA_DIRS")).split(':'));
for (const QString &dir : xdgDataDirs) {
QString desktopPath(
QDir(QDir(dir).filePath("applications")).filePath(
desktopFile));
if (QFile::exists(desktopPath)) {
m_desktopPath = desktopPath;
break;
}
}
}
return m_desktopPath;
}
const QString & ApplicationImpl::icon() {
if (m_icon.isEmpty()) {
QString path(desktopPath());
if (!path.isEmpty()) {
QSettings settings(path, QSettings::IniFormat);
settings.beginGroup("Desktop Entry");
m_icon = settings.value("Icon").toString();
settings.endGroup();
}
}
return m_icon;
}
QList ApplicationImpl::actionGroups() const {
return QList();
}
QList ApplicationImpl::menuModels() const {
return QList();
}
QString ApplicationImpl::messageSender() {
QString sender("local");
if (calledFromDBus()) {
sender = message().service();
}
return sender;
}
/**
* Window ID 0 is the "all windows" context
*/
void ApplicationImpl::AddSources(const QList &actions,
const QList &descriptions) {
QString name(messageSender());
QMap, WindowContext::MenuDefinition> definitions;
for (const Action &action : actions) {
WindowContext::MenuDefinition definition(name);
definition.actionPath = action.m_object;
definition.actionPrefix = action.m_prefix;
QPair id(action.m_windowId, action.m_context);
definitions[id] = definition;
}
for (const Description &description : descriptions) {
QPair id(description.m_windowId, description.m_context);
if (definitions.contains(id)) {
WindowContext::MenuDefinition &definition(definitions[id]);
definition.menuPath = description.m_object;
} else {
WindowContext::MenuDefinition definition(name);
definition.menuPath = description.m_object;
definitions[id] = definition;
}
}
for (auto it(definitions.constBegin()); it != definitions.constEnd();
++it) {
const QPair &id(it.key());
WindowContext::Ptr window = windowContext(id.first);
if (window.isNull()) {
qWarning() << "Tried to add model source for unknown window context"
<< id.first;
continue;
}
window->addMenu(id.second, it.value());
}
}
void ApplicationImpl::SetWindowContext(uint windowId, const QString &context) {
WindowContext::Ptr window = windowContext(windowId);
if (window.isNull()) {
qWarning() << "Tried to set context on unknown window context"
<< windowId << m_applicationId;
return;
}
window->setContext(context);
}
./service/HudService.cpp 0000644 0000156 0000165 00000001544 12704153516 015312 0 ustar jenkins jenkins /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see .
*
* Author: Pete Woods
*/
#include
using namespace hud::service;
HudService::HudService(QObject *parent) :
QObject(parent) {
}
HudService::~HudService() {
}
./service/GMenuWindowCollector.cpp 0000644 0000156 0000165 00000006551 12704153516 017326 0 ustar jenkins jenkins /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see .
*
* Author: Pete Woods
*/
#include
#include
#include
#include
#include
#include
using namespace hud::service;
using namespace qtgmenu;
static const QStringList GMENU_WINDOW_PROPERTIES( { "_GTK_UNIQUE_BUS_NAME",
"_GTK_APP_MENU_OBJECT_PATH", "_GTK_MENUBAR_OBJECT_PATH",
"_GTK_APPLICATION_OBJECT_PATH", "_GTK_WINDOW_OBJECT_PATH",
"_UNITY_OBJECT_PATH" });
GMenuWindowCollector::GMenuWindowCollector(unsigned int windowId,
const QString &applicationId,
QSharedPointer windowStack,
Factory &factory) :
m_windowStack(windowStack) {
QDBusPendingReply windowPropertiesReply(
windowStack->GetWindowProperties(windowId, applicationId,
GMENU_WINDOW_PROPERTIES));
windowPropertiesReply.waitForFinished();
if (windowPropertiesReply.isError()) {
qWarning() << windowPropertiesReply.error();
return;
}
QStringList windowProperties(windowPropertiesReply);
if (windowProperties.isEmpty()) {
return;
}
m_busName = windowProperties.at(0);
// We're using the existence of the bus name property to determine
// if this window has GMenus available at all.
if (m_busName.isEmpty()) {
return;
}
QSet