hud-14.10+17.10.20170619/ 0000775 0001750 0001750 00000000000 13121716557 015311 5 ustar didrocks didrocks 0000000 0000000 hud-14.10+17.10.20170619/tools-vala/ 0000775 0001750 0001750 00000000000 13121716557 017372 5 ustar didrocks didrocks 0000000 0000000 hud-14.10+17.10.20170619/tools-vala/hud-gtk.vala 0000664 0001750 0001750 00000013773 13121713174 021605 0 ustar didrocks didrocks 0000000 0000000 extern const string HUD_GTK_DATADIR;
namespace HudGtk {
public class CellRendererVariant : Gtk.CellRendererText {
public Variant value {
set {
if (value != null) {
text = value.print (false);
} else {
text = "(null)";
}
}
}
}
class Window : Gtk.ApplicationWindow {
Gtk.Label voice_label;
Gtk.ListStore model;
Gtk.ListStore appstack_model;
Gtk.Entry entry;
HudClient.Query query;
void results_row_added (Dee.Model results, Dee.ModelIter result_iter) {
var pos = results.get_position(result_iter);
Gtk.TreeIter iter;
model.insert(out iter, (int)pos);
model.set(iter, 0, query.results_get_command_name(result_iter));
model.set(iter, 1, query.results_get_description(result_iter));
model.set(iter, 2, query.results_get_shortcut(result_iter));
/* Distance isn't in the API because it's internal, but this
is a debugging tool so we're leavinging here */
model.set(iter, 3, results.get_uint32(result_iter, 6));
model.set(iter, 4, Markup.escape_text(query.results_get_command_id(result_iter).print(true)));
model.set(iter, 5, query.results_get_command_id(result_iter));
}
void results_row_removed (Dee.Model results, Dee.ModelIter result_iter) {
var pos = results.get_position(result_iter);
string spath = "%d";
spath = spath.printf(pos);
Gtk.TreePath path = new Gtk.TreePath.from_string(spath);
Gtk.TreeIter iter;
model.get_iter(out iter, path);
#if VALA_0_36
model.remove(ref iter);
#else
model.remove(iter);
#endif
}
void appstack_results_row_added (Dee.Model results, Dee.ModelIter result_iter) {
var pos = results.get_position(result_iter);
Gtk.TreeIter iter;
appstack_model.insert(out iter, (int)pos);
appstack_model.set(iter, 0, query.appstack_get_app_id(result_iter));
appstack_model.set(iter, 1, query.appstack_get_app_icon(result_iter));
}
void appstack_results_row_removed (Dee.Model results, Dee.ModelIter result_iter) {
var pos = results.get_position(result_iter);
string spath = "%d";
spath = spath.printf(pos);
Gtk.TreePath path = new Gtk.TreePath.from_string(spath);
Gtk.TreeIter iter;
appstack_model.get_iter(out iter, path);
#if VALA_0_36
appstack_model.remove(ref iter);
#else
appstack_model.remove(iter);
#endif
}
void entry_text_changed (Object object, ParamSpec pspec) {
query.set_query(entry.text);
}
void voice_pressed (Gtk.Button button) {
query.voice_query();
}
void view_activated (Gtk.TreeView view, Gtk.TreePath path, Gtk.TreeViewColumn column) {
Gtk.TreeIter iter;
Variant key;
model.get_iter (out iter, path);
model.get (iter, 5, out key);
query.execute_command(key, 0);
}
void voice_query_loading (HudClient.Query proxy) {
debug("Voice query is loading");
voice_label.label = "Loading";
}
void voice_query_failed (HudClient.Query proxy, string cause) {
debug("Voice query failed, cause=[%s]", cause);
voice_label.label = "Idle";
var dialog = new Gtk.MessageDialog(null,Gtk.DialogFlags.MODAL,Gtk.MessageType.ERROR, Gtk.ButtonsType.OK, "Voice query failed, cause=[%s]", cause);
dialog.set_title("Voice query failed");
dialog.run();
dialog.destroy();
}
void voice_query_listening (HudClient.Query proxy) {
debug("Voice query is listening");
voice_label.label = "Listening";
}
void voice_query_heard_something (HudClient.Query proxy) {
debug("Voice query has heard something");
voice_label.label = "Heard Something";
}
void voice_query_finished (HudClient.Query proxy, string query) {
debug("Voice query is finished, query=[%s]", query);
voice_label.label = "Idle";
entry.text = query;
}
void appstack_view_activated (Gtk.TreeView view, Gtk.TreePath path, Gtk.TreeViewColumn column) {
Gtk.TreeIter iter;
string key;
appstack_model.get_iter (out iter, path);
appstack_model.get (iter, 0, out key);
query.set_appstack_app(key);
}
public Window (Gtk.Application application) {
Object (application: application, title: "Hud");
set_default_size (500, 300);
query = new HudClient.Query("");
query.models_changed.connect ( models_changed );
}
void models_changed(HudClient.Query proxy) {
query.models_changed.disconnect ( models_changed );
var builder = new Gtk.Builder ();
try {
new CellRendererVariant ();
builder.add_from_file (HUD_GTK_DATADIR + "/hud-gtk.ui");
} catch (Error e) {
error (e.message);
}
voice_label = builder.get_object ("voice-status") as Gtk.Label;
query.voice_query_loading.connect ( voice_query_loading );
query.voice_query_failed.connect ( voice_query_failed );
query.voice_query_listening.connect ( voice_query_listening );
query.voice_query_heard_something.connect ( voice_query_heard_something );
query.voice_query_finished.connect ( voice_query_finished );
Dee.Model results = query.get_results_model();
results.row_added.connect (results_row_added);
results.row_removed.connect (results_row_removed);
Dee.Model appstack_results = query.get_appstack_model();
appstack_results.row_added.connect (appstack_results_row_added);
appstack_results.row_removed.connect (appstack_results_row_removed);
entry = builder.get_object ("entry") as Gtk.Entry;
model = builder.get_object ("liststore") as Gtk.ListStore;
entry.notify["text"].connect (entry_text_changed);
(builder.get_object ("voice") as Gtk.Button).clicked.connect (voice_pressed);
(builder.get_object ("treeview") as Gtk.TreeView).row_activated.connect (view_activated);
add (builder.get_object ("grid") as Gtk.Widget);
appstack_model = builder.get_object ("appstack_liststore") as Gtk.ListStore;
(builder.get_object ("appstack_treeview") as Gtk.TreeView).row_activated.connect (appstack_view_activated);
}
}
class Application : Gtk.Application {
protected override void activate () {
new Window (this).show_all ();
}
public Application () {
Object (application_id: "com.canonical.HudGtk");
}
}
}
int main (string[] args) {
return new HudGtk.Application ().run (args);
}
hud-14.10+17.10.20170619/tools-vala/CMakeLists.txt 0000664 0001750 0001750 00000003143 13121713174 022123 0 ustar didrocks didrocks 0000000 0000000
if(${VALA_FOUND})
if(${INTROSPECTION_FOUND})
set(HEADER_PATH "${CMAKE_CURRENT_BINARY_DIR}/hud-gtk.h")
set(SYMBOLS_PATH "${CMAKE_CURRENT_BINARY_DIR}/hud-gtk.def")
set(HUD_GTK_DATADIR "${CMAKE_INSTALL_FULL_DATADIR}/hud-gtk")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-deprecated-declarations")
###########################
# HUD Gtk Vala Generation
###########################
set(VALA_OPTIONS)
foreach(DIR ${HUD_CLIENT_INCLUDE_DIRS})
list(APPEND VALA_OPTIONS "--vapidir" ${DIR})
endforeach()
vala_init (hud-gtk-vala
PACKAGES
Dee-1.0
gtk+-3.0
HudClient-2
OPTIONS
${VALA_OPTIONS}
DEPENDS
hud-client-vapi
)
vala_add(hud-gtk-vala hud-gtk.vala)
vala_finish(hud-gtk-vala
SOURCES
project_VALA_SOURCES
OUTPUTS
project_VALA_C
GENERATE_HEADER
${HEADER_PATH}
GENERATE_SYMBOLS
${SYMBOLS_PATH}
)
set_source_files_properties(${project_VALA_SOURCES}
PROPERTIES HEADER_FILE_ONLY TRUE)
set(project_SOURCES ${project_VALA_SOURCES} ${project_VALA_C} ${SYMBOLS_PATH})
###########################
# HUD Gtk Executable
###########################
include_directories(${HUD_CLIENT_INCLUDE_DIRS})
add_definitions(-DHUD_GTK_DATADIR="${HUD_GTK_DATADIR}")
add_executable (hud-gtk-exec ${project_SOURCES})
set_target_properties(hud-gtk-exec PROPERTIES OUTPUT_NAME "hud-gtk")
target_link_libraries(hud-gtk-exec
hud-client
${GTK3_LIBRARIES}
${DEE_LIBRARIES}
)
###########################
# Installation
###########################
install(
TARGETS hud-gtk-exec
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
install(
FILES hud-gtk.ui
DESTINATION ${HUD_GTK_DATADIR}
)
endif()
endif()
hud-14.10+17.10.20170619/tools-vala/hud-gtk.ui 0000664 0001750 0001750 00000021477 13121713174 021277 0 ustar didrocks didrocks 0000000 0000000
hud-14.10+17.10.20170619/common/ 0000775 0001750 0001750 00000000000 13121716557 016601 5 ustar didrocks didrocks 0000000 0000000 hud-14.10+17.10.20170619/common/ActionGroup.cpp 0000664 0001750 0001750 00000003064 13121713174 021532 0 ustar didrocks didrocks 0000000 0000000 /*
* 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
using namespace hud::common;
QDBusArgument & operator<<(QDBusArgument &argument,
const ActionGroup &actionGroup) {
argument.beginStructure();
argument << QDBusVariant(actionGroup.m_variant) << actionGroup.m_string
<< actionGroup.m_object;
argument.endStructure();
return argument;
}
const QDBusArgument & operator>>(const QDBusArgument &argument,
ActionGroup &actionGroup) {
argument.beginStructure();
argument >> actionGroup.m_variant >> actionGroup.m_string
>> actionGroup.m_object;
argument.endStructure();
return argument;
}
ActionGroup::ActionGroup() {
}
ActionGroup::~ActionGroup() {
}
void ActionGroup::registerMetaTypes() {
qRegisterMetaType();
qDBusRegisterMetaType();
qRegisterMetaType>();
qDBusRegisterMetaType>();
}
hud-14.10+17.10.20170619/common/ActionGroup.h 0000664 0001750 0001750 00000002563 13121713174 021202 0 ustar didrocks didrocks 0000000 0000000 /*
* 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_COMMON_ACTIONGROUP_H_
#define HUD_COMMON_ACTIONGROUP_H_
#include
#include
namespace hud {
namespace common {
class ActionGroup {
public:
ActionGroup();
virtual ~ActionGroup();
static void registerMetaTypes();
//FIXME Give these proper names
QVariant m_variant;
QString m_string;
QDBusObjectPath m_object;
};
}
}
Q_DECL_EXPORT
QDBusArgument &operator<<(QDBusArgument &argument,
const hud::common::ActionGroup &actionGroup);
Q_DECL_EXPORT
const QDBusArgument &operator>>(const QDBusArgument &argument,
hud::common::ActionGroup &actionGroup);
Q_DECLARE_METATYPE(hud::common::ActionGroup)
#endif /* HUD_COMMON_ACTIONGROUP_H_ */
hud-14.10+17.10.20170619/common/WindowInfo.cpp 0000664 0001750 0001750 00000003547 13121713174 021371 0 ustar didrocks didrocks 0000000 0000000 /*
* 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
using namespace hud::common;
QDBusArgument & operator<<(QDBusArgument &a, const WindowInfo &wi) {
a.beginStructure();
a << wi.window_id << wi.app_id << wi.focused << wi.stage;
a.endStructure();
return a;
}
const QDBusArgument & operator>>(const QDBusArgument &a, WindowInfo &wi) {
a.beginStructure();
uint stage;
a >> wi.window_id >> wi.app_id >> wi.focused >> stage;
a.endStructure();
wi.stage = static_cast(stage);
return a;
}
WindowInfo::WindowInfo() :
window_id(0), focused(false), stage(MAIN) {
}
WindowInfo::WindowInfo(unsigned int window_id, const QString &app_id,
bool focused, Stage stage) :
window_id(window_id), app_id(app_id), focused(focused), stage(stage) {
}
WindowInfo::~WindowInfo() {
}
bool WindowInfo::operator==(const WindowInfo &other) const {
return (window_id == other.window_id) && (app_id == other.app_id)
&& (focused == other.focused) && (stage == other.stage);
}
void WindowInfo::registerMetaTypes() {
qRegisterMetaType();
qRegisterMetaType();
qDBusRegisterMetaType();
qDBusRegisterMetaType();
}
hud-14.10+17.10.20170619/common/AppstackModel.h 0000664 0001750 0001750 00000002366 13121713174 021500 0 ustar didrocks didrocks 0000000 0000000 /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of version 3 of the GNU Lesser General Public License as published
* by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*
* Author: Pete Woods
*/
#ifndef HUD_COMMON_APPSTACKMODEL_H_
#define HUD_COMMON_APPSTACKMODEL_H_
#include
#include
namespace hud {
namespace common {
class AppstackModel: public HudDee {
public:
typedef enum {
ITEM_TYPE_FOCUSED_APP,
ITEM_TYPE_SIDESTAGE_APP,
ITEM_TYPE_BACKGROUND_APP,
ITEM_TYPE_INDICATOR
} ItemType;
explicit AppstackModel(unsigned int id);
virtual ~AppstackModel();
void addApplication(const QString &applicationId, const QString &iconName,
ItemType itemType);
protected:
};
}
}
#endif /* HUD_COMMON_APPSTACKMODEL_H_ */
hud-14.10+17.10.20170619/common/Description.h 0000664 0001750 0001750 00000002527 13121713174 021233 0 ustar didrocks didrocks 0000000 0000000 /*
* 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_COMMON_DESCRIPTION_H_
#define HUD_COMMON_DESCRIPTION_H_
#include
#include
namespace hud {
namespace common {
class Description {
public:
Description();
virtual ~Description();
static void registerMetaTypes();
unsigned int m_windowId;
QString m_context;
QDBusObjectPath m_object;
};
}
}
Q_DECL_EXPORT
QDBusArgument &operator<<(QDBusArgument &argument,
const hud::common::Description &description);
Q_DECL_EXPORT
const QDBusArgument &operator>>(const QDBusArgument &argument,
hud::common::Description &description);
Q_DECLARE_METATYPE(hud::common::Description)
#endif /* HUD_COMMON_DESCRIPTION_H_ */
hud-14.10+17.10.20170619/common/HudDee.h 0000664 0001750 0001750 00000002600 13121713174 020076 0 ustar didrocks didrocks 0000000 0000000 /*
* 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_COMMON_HUDDEE_H_
#define HUD_COMMON_HUDDEE_H_
#include
typedef struct _GVariant GVariant;
typedef int (*CompareRowFunc)(GVariant** row1, GVariant** row2,
void* user_data);
namespace hud {
namespace common {
class HudDee {
public:
explicit HudDee(const std::string &resultsName);
virtual ~HudDee();
const std::string & name() const;
void beginChangeset();
void endChangeset();
protected:
void setSchema(const char* const *columnSchemas, unsigned int numColumns);
void appendRow(GVariant **row_members);
void insertRowSorted(GVariant **row_members, CompareRowFunc cmp_func);
class Priv;
std::shared_ptr p;
};
}
}
#endif /* HUD_COMMON_HUDDEE_H_ */
hud-14.10+17.10.20170619/common/NameObject.cpp 0000664 0001750 0001750 00000003735 13121713174 021314 0 ustar didrocks didrocks 0000000 0000000 /*
* 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
using namespace hud::common;
QDBusArgument & operator<<(QDBusArgument &argument,
const NameObject &nameObject) {
argument.beginStructure();
argument << nameObject.m_name << nameObject.m_object;
argument.endStructure();
return argument;
}
const QDBusArgument & operator>>(const QDBusArgument &argument,
NameObject &nameObject) {
argument.beginStructure();
argument >> nameObject.m_name >> nameObject.m_object;
argument.endStructure();
return argument;
}
namespace hud {
namespace common {
NameObject::NameObject() {
}
NameObject::NameObject(const QString &name, const QDBusObjectPath &object) :
m_name(name), m_object(object) {
}
NameObject::NameObject(const NameObject &other) :
m_name(other.m_name), m_object(other.m_object) {
}
NameObject & NameObject::operator=(const NameObject &other) {
m_name = other.m_name;
m_object = other.m_object;
return *this;
}
bool NameObject::operator==(const NameObject &other) const {
return m_name == other.m_name && m_object == other.m_object;
}
NameObject::~NameObject() {
}
void NameObject::registerMetaTypes() {
qRegisterMetaType();
qDBusRegisterMetaType();
qRegisterMetaType>();
qDBusRegisterMetaType>();
}
}
}
hud-14.10+17.10.20170619/common/WindowInfo.h 0000664 0001750 0001750 00000003140 13121713174 021023 0 ustar didrocks didrocks 0000000 0000000 /*
* 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_COMMON_WINDOWINFO_H_
#define HUD_COMMON_WINDOWINFO_H_
#include
#include
namespace hud {
namespace common {
class WindowInfo {
public:
enum Stage {
MAIN, SIDE, WINDOWED
};
unsigned int window_id;
QString app_id;
bool focused;
unsigned int stage;
explicit WindowInfo();
explicit WindowInfo(unsigned int window_id, const QString &app_id,
bool focused, Stage stage = MAIN);
virtual ~WindowInfo();
bool operator==(const WindowInfo &other) const;
static void registerMetaTypes();
};
typedef QList WindowInfoList;
}
}
Q_DECL_EXPORT
QDBusArgument &operator<<(QDBusArgument &a,
const hud::common::WindowInfo &aidf);
Q_DECL_EXPORT
const QDBusArgument &operator>>(const QDBusArgument &a,
hud::common::WindowInfo &aidf);
Q_DECLARE_METATYPE(hud::common::WindowInfo)
Q_DECLARE_METATYPE(hud::common::WindowInfoList)
#endif /* HUD_COMMON_WINDOWINFO_H_ */
hud-14.10+17.10.20170619/common/ResultsModel.h 0000664 0001750 0001750 00000002471 13121713174 021370 0 ustar didrocks didrocks 0000000 0000000 /*
* 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_COMMON_RESULTSMODEL_H_
#define HUD_COMMON_RESULTSMODEL_H_
#include
#include
#include
#include
namespace hud {
namespace common {
class ResultsModel: public HudDee {
public:
explicit ResultsModel(unsigned int id);
virtual ~ResultsModel();
void setResults();
void addResult(qulonglong id, const QString &command,
const QList> &commandHighlights,
const QString &description,
const QList> &descriptionHighlights,
const QString &shortcut, int distance, bool parameterized);
};
}
}
#endif /* HUD_COMMON_RESULTSMODEL_H_ */
hud-14.10+17.10.20170619/common/shared-values.h 0000664 0001750 0001750 00000001662 13121713174 021512 0 ustar didrocks didrocks 0000000 0000000 /*
Values that we share between the various objects
Copyright 2011 Canonical Ltd.
Authors:
Ted Gould
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 .
*/
#ifndef SHARED_VALUES_H__
#define SHARED_VALUES_H__
#define DBUS_NAME "com.canonical.hud"
#define DBUS_PATH "/com/canonical/hud"
#define DBUS_IFACE "com.canonical.hud"
#define DB_SEPARATOR "||"
#endif /* SHARED_VALUES_H__ */
hud-14.10+17.10.20170619/common/HudDee.cpp 0000664 0001750 0001750 00000003474 13121713174 020443 0 ustar didrocks didrocks 0000000 0000000 /*
* 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
using namespace std;
using namespace hud::common;
class HudDee::Priv {
public:
Priv() :
m_model(nullptr) {
}
~Priv() {
g_clear_object(&m_model);
}
DeeModel *m_model;
string m_name;
};
HudDee::HudDee(const string &name) :
p(new Priv()) {
p->m_name = name;
p->m_model = dee_shared_model_new(p->m_name.data());
}
HudDee::~HudDee() {
}
const string & HudDee::name() const {
return p->m_name;
}
void HudDee::setSchema(const char* const *columnSchemas,
unsigned int numColumns) {
dee_model_set_schema_full(p->m_model, columnSchemas, numColumns);
}
void HudDee::beginChangeset() {
dee_model_begin_changeset(p->m_model);
dee_model_clear(p->m_model);
}
void HudDee::appendRow(GVariant **row_members) {
dee_model_append_row(p->m_model, row_members);
}
void HudDee::insertRowSorted(GVariant **row_members, CompareRowFunc cmp_func) {
dee_model_insert_row_sorted(p->m_model, row_members, cmp_func, NULL);
}
void HudDee::endChangeset() {
// dee_shared_model_flush_revision_queue(DEE_SHARED_MODEL(p->m_model));
dee_model_end_changeset(p->m_model);
}
hud-14.10+17.10.20170619/common/GDBusHelper.h 0000664 0001750 0001750 00000003307 13121713174 021051 0 ustar didrocks didrocks 0000000 0000000 /*
* Copyright (C) 2015 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 COMMON_GDBUSHELPER_H_
#define COMMON_GDBUSHELPER_H_
#include
static inline GDBusConnection * newSessionBusConnection(GCancellable* cancellable)
{
GError *error = NULL;
gchar *address = g_dbus_address_get_for_bus_sync(G_BUS_TYPE_SESSION,
NULL, &error);
if (!address) {
g_assert(error != NULL);
if (error->domain != G_IO_ERROR
|| error->code != G_IO_ERROR_CANCELLED) {
}
g_error_free(error);
return NULL;
}
error = NULL;
GDBusConnection* connection =
g_dbus_connection_new_for_address_sync(address,
(GDBusConnectionFlags) (G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT
| G_DBUS_CONNECTION_FLAGS_MESSAGE_BUS_CONNECTION),
NULL, cancellable, &error);
g_free(address);
if (connection == NULL) {
g_assert(error != NULL);
if (error->domain != G_IO_ERROR
|| error->code != G_IO_ERROR_CANCELLED) {
}
g_error_free(error);
return NULL;
}
g_dbus_connection_set_exit_on_close(connection, FALSE);
return connection;
}
#endif // COMMON_GDBUSHELPER_H_
hud-14.10+17.10.20170619/common/Suggestion.h 0000664 0001750 0001750 00000003271 13121713174 021074 0 ustar didrocks didrocks 0000000 0000000 /*
* 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_COMMON_SUGGESTION_H_
#define HUD_COMMON_SUGGESTION_H_
#include
#include
namespace hud {
namespace common {
/**
* sssssv
* Description
* Icon
* 3 Blanks ??
* ID
*/
class Q_DECL_EXPORT Suggestion {
public:
explicit Suggestion();
explicit Suggestion(qulonglong id, const QString &commandName,
const QList> &commandHighlights,
const QString &description,
const QList> &descriptionHighlights,
const QString &icon);
virtual ~Suggestion();
static void registerMetaTypes();
QString m_description;
QString m_icon;
QString m_unknown1;
QString m_unknown2;
QString m_unknown3;
QVariant m_id;
};
}
}
Q_DECL_EXPORT
QDBusArgument &operator<<(QDBusArgument &argument,
const hud::common::Suggestion &suggestion);
Q_DECL_EXPORT
const QDBusArgument &operator>>(const QDBusArgument &argument,
hud::common::Suggestion &suggestion);
Q_DECLARE_METATYPE(hud::common::Suggestion)
#endif /* HUD_COMMON_SUGGESTION_H_ */
hud-14.10+17.10.20170619/common/ResultsModel.cpp 0000664 0001750 0001750 00000005723 13121713174 021726 0 ustar didrocks didrocks 0000000 0000000 /*
* 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
const QString RESULTS_FORMAT_STRING("com.canonical.hud.query%1.results");
using namespace hud::common;
ResultsModel::ResultsModel(unsigned int id) :
HudDee(RESULTS_FORMAT_STRING.arg(id).toStdString()) {
setSchema(results_model_schema, G_N_ELEMENTS(results_model_schema));
}
ResultsModel::~ResultsModel() {
}
void ResultsModel::addResult(qulonglong id, const QString &commandName,
const QList> &commandHighlights,
const QString &description,
const QList> &descriptionHighlights,
const QString &shortcut, int distance, bool parameterized) {
GVariant *actionh = NULL;
if (commandHighlights.isEmpty()) {
actionh = g_variant_new_array(G_VARIANT_TYPE("(ii)"), NULL, 0);
} else {
GVariantBuilder builder;
g_variant_builder_init(&builder, G_VARIANT_TYPE("a(ii)"));
for (const QPair &highlight : commandHighlights) {
g_variant_builder_add(&builder, "(ii)", highlight.first,
highlight.second);
}
actionh = g_variant_builder_end(&builder);
}
GVariant *desch = NULL;
if (descriptionHighlights.isEmpty()) {
desch = g_variant_new_array(G_VARIANT_TYPE("(ii)"), NULL, 0);
} else {
GVariantBuilder builder;
g_variant_builder_init(&builder, G_VARIANT_TYPE("a(ii)"));
for (const QPair &highlight : descriptionHighlights) {
g_variant_builder_add(&builder, "(ii)", highlight.first,
highlight.second);
}
desch = g_variant_builder_end(&builder);
}
GVariant *columns[HUD_QUERY_RESULTS_COUNT + 1];
columns[HUD_QUERY_RESULTS_COMMAND_ID] = g_variant_new_variant(
g_variant_new_uint64(id));
columns[HUD_QUERY_RESULTS_COMMAND_NAME] = g_variant_new_string(
commandName.toUtf8().data());
columns[HUD_QUERY_RESULTS_COMMAND_HIGHLIGHTS] = actionh;
columns[HUD_QUERY_RESULTS_DESCRIPTION] = g_variant_new_string(
description.toUtf8().data());
columns[HUD_QUERY_RESULTS_DESCRIPTION_HIGHLIGHTS] = desch;
columns[HUD_QUERY_RESULTS_SHORTCUT] = g_variant_new_string(
shortcut.toUtf8().data());
columns[HUD_QUERY_RESULTS_DISTANCE] = g_variant_new_uint32(distance);
columns[HUD_QUERY_RESULTS_PARAMETERIZED] = g_variant_new_boolean(
parameterized);
columns[HUD_QUERY_RESULTS_COUNT] = NULL;
appendRow(columns);
}
hud-14.10+17.10.20170619/common/Action.h 0000664 0001750 0001750 00000002464 13121713174 020165 0 ustar didrocks didrocks 0000000 0000000 /*
* 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_COMMON_ACTION_H_
#define HUD_COMMON_ACTION_H_
#include
#include
namespace hud {
namespace common {
class Action {
public:
Action();
virtual ~Action();
static void registerMetaTypes();
unsigned int m_windowId;
QString m_context;
QString m_prefix;
QDBusObjectPath m_object;
};
}
}
Q_DECL_EXPORT
QDBusArgument &operator<<(QDBusArgument &argument,
const hud::common::Action &action);
Q_DECL_EXPORT
const QDBusArgument &operator>>(const QDBusArgument &argument,
hud::common::Action &action);
Q_DECLARE_METATYPE(hud::common::Action)
#endif /* HUD_COMMON_ACTION_H_ */
hud-14.10+17.10.20170619/common/DBusTypes.h 0000664 0001750 0001750 00000003514 13121713174 020627 0 ustar didrocks didrocks 0000000 0000000 /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of version 3 of the GNU Lesser General Public License as published
* by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*
* Author: Pete Woods
*/
#ifndef HUD_COMMON_DBUSTYPES_H_
#define HUD_COMMON_DBUSTYPES_H_
#include
#include
#include
#include
#include
#include
namespace hud {
namespace common {
class DBusTypes {
public:
Q_DECL_EXPORT
static const QString HUD_SERVICE_DBUS_NAME;
Q_DECL_EXPORT
static const QString HUD_SERVICE_DBUS_PATH;
Q_DECL_EXPORT
static const QString WINDOW_STACK_DBUS_NAME;
Q_DECL_EXPORT
static const QString WINDOW_STACK_DBUS_PATH;
Q_DECL_EXPORT
static const QString APPMENU_REGISTRAR_DBUS_NAME;
Q_DECL_EXPORT
static const QString APPMENU_REGISTRAR_DBUS_PATH;
Q_DECL_EXPORT
static const QString BAMF_DBUS_NAME;
Q_DECL_EXPORT
static const QString BAMF_MATCHER_DBUS_PATH;
Q_DECL_EXPORT
static const QString UNITY_VOICE_DBUS_NAME;
Q_DECL_EXPORT
static const QString UNITY_VOICE_DBUS_PATH;
Q_DECL_EXPORT
static void registerMetaTypes();
Q_DECL_EXPORT
static QString queryPath(unsigned int id);
Q_DECL_EXPORT
static QString applicationPath(const QString &applicationId);
};
}
}
#endif /* HUD_COMMON_DBUSTYPES_H_ */
hud-14.10+17.10.20170619/common/query-columns.h 0000664 0001750 0001750 00000005164 13121713174 021573 0 ustar didrocks didrocks 0000000 0000000 /*
* Copyright © 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: Ted Gould
*/
#ifndef __QUERY_COLUMNS_H__
#define __QUERY_COLUMNS_H__
enum _HudQueryResultsColumns {
HUD_QUERY_RESULTS_COMMAND_ID = 0,
HUD_QUERY_RESULTS_COMMAND_NAME,
HUD_QUERY_RESULTS_COMMAND_HIGHLIGHTS,
HUD_QUERY_RESULTS_DESCRIPTION,
HUD_QUERY_RESULTS_DESCRIPTION_HIGHLIGHTS,
HUD_QUERY_RESULTS_SHORTCUT,
HUD_QUERY_RESULTS_DISTANCE,
HUD_QUERY_RESULTS_PARAMETERIZED,
/* Last */
HUD_QUERY_RESULTS_COUNT
};
typedef enum _HudQueryResultsColumns HudQueryResultsColumns;
#define HUD_QUERY_RESULTS_COMMAND_ID_TYPE "v"
#define HUD_QUERY_RESULTS_COMMAND_NAME_TYPE "s"
#define HUD_QUERY_RESULTS_COMMAND_HIGHLIGHTS_TYPE "a(ii)"
#define HUD_QUERY_RESULTS_DESCRIPTION_TYPE "s"
#define HUD_QUERY_RESULTS_DESCRIPTION_HIGHLIGHTS_TYPE "a(ii)"
#define HUD_QUERY_RESULTS_SHORTCUT_TYPE "s"
#define HUD_QUERY_RESULTS_DISTANCE_TYPE "u"
#define HUD_QUERY_RESULTS_PARAMETERIZED_TYPE "b"
/* Schema that is used in the DeeModel representing
the results */
static const char * results_model_schema[HUD_QUERY_RESULTS_COUNT] = {
HUD_QUERY_RESULTS_COMMAND_ID_TYPE,
HUD_QUERY_RESULTS_COMMAND_NAME_TYPE,
HUD_QUERY_RESULTS_COMMAND_HIGHLIGHTS_TYPE,
HUD_QUERY_RESULTS_DESCRIPTION_TYPE,
HUD_QUERY_RESULTS_DESCRIPTION_HIGHLIGHTS_TYPE,
HUD_QUERY_RESULTS_SHORTCUT_TYPE,
HUD_QUERY_RESULTS_DISTANCE_TYPE,
HUD_QUERY_RESULTS_PARAMETERIZED_TYPE, };
enum _HudQueryAppstackColumns {
HUD_QUERY_APPSTACK_APPLICATION_ID = 0,
HUD_QUERY_APPSTACK_ICON_NAME,
HUD_QUERY_APPSTACK_ITEM_TYPE,
/* Last */
HUD_QUERY_APPSTACK_COUNT
};
typedef enum _HudQueryAppstackColumns HudQueryAppstackColumns;
#define HUD_QUERY_APPSTACK_APPLICATION_ID_TYPE "s"
#define HUD_QUERY_APPSTACK_ICON_NAME_TYPE "s"
#define HUD_QUERY_APPSTACK_ITEM_TYPE_TYPE "i"
/* Schema that is used in the DeeModel representing
the appstack */
static const char * appstack_model_schema[HUD_QUERY_APPSTACK_COUNT] = {
HUD_QUERY_APPSTACK_APPLICATION_ID_TYPE,
HUD_QUERY_APPSTACK_ICON_NAME_TYPE,
HUD_QUERY_APPSTACK_ITEM_TYPE_TYPE, };
#endif /* __QUERY_COLUMNS_H__ */
hud-14.10+17.10.20170619/common/CMakeLists.txt 0000664 0001750 0001750 00000001501 13121713174 021326 0 ustar didrocks didrocks 0000000 0000000
###########################
# Hud Common
###########################
set(HUD_COMMON_SOURCES
AppstackModel.cpp
Action.cpp
ActionGroup.cpp
Description.cpp
DBusTypes.cpp
HudDee.cpp
MenuModel.cpp
NameObject.cpp
ResultsModel.cpp
Suggestion.cpp
WindowInfo.cpp
)
set_source_files_properties(
${WINDOW_STACK_XML}
PROPERTIES
INCLUDE "common/WindowInfo.h"
)
qt5_add_dbus_interface(
HUD_COMMON_SOURCES
${WINDOW_STACK_XML}
WindowStackInterface
)
set_source_files_properties(
${HUD_APP_XML}
PROPERTIES
INCLUDE "common/DBusTypes.h"
)
qt5_add_dbus_interface(
HUD_COMMON_SOURCES
${HUD_APP_XML}
ApplicationInterface
)
add_library(hud-common
STATIC
${HUD_COMMON_SOURCES}
)
qt5_use_modules(
hud-common
Core
DBus
)
target_link_libraries(
hud-common
${GLIB2_LIBRARIES}
${DEE_LIBRARIES}
)
hud-14.10+17.10.20170619/common/NameObject.h 0000664 0001750 0001750 00000003045 13121713174 020753 0 ustar didrocks didrocks 0000000 0000000 /*
* 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_COMMON_NAMEOBJECT_H_
#define HUD_COMMON_NAMEOBJECT_H_
#include
#include
namespace hud {
namespace common {
class Q_DECL_EXPORT NameObject {
public:
explicit NameObject();
explicit NameObject(const QString &name, const QDBusObjectPath &object);
explicit NameObject(const NameObject &other);
NameObject & operator=(const NameObject &other);
bool operator==(const NameObject &other) const;
virtual ~NameObject();
static void registerMetaTypes();
QString m_name;
QDBusObjectPath m_object;
};
}
}
Q_DECL_EXPORT
QDBusArgument &operator<<(QDBusArgument &argument,
const hud::common::NameObject &nameObject);
Q_DECL_EXPORT
const QDBusArgument &operator>>(const QDBusArgument &argument,
hud::common::NameObject &nameObject);
Q_DECLARE_METATYPE(hud::common::NameObject)
#endif /* HUD_COMMON_NAMEOBJECT_H_ */
hud-14.10+17.10.20170619/common/Action.cpp 0000664 0001750 0001750 00000002773 13121713174 020523 0 ustar didrocks didrocks 0000000 0000000 /*
* 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
using namespace hud::common;
QDBusArgument & operator<<(QDBusArgument &argument, const Action &action) {
argument.beginStructure();
argument << action.m_windowId << action.m_context << action.m_prefix
<< action.m_object;
argument.endStructure();
return argument;
}
const QDBusArgument & operator>>(const QDBusArgument &argument,
Action &action) {
argument.beginStructure();
argument >> action.m_windowId >> action.m_context >> action.m_prefix
>> action.m_object;
argument.endStructure();
return argument;
}
Action::Action() :
m_windowId(0) {
}
Action::~Action() {
}
void Action::registerMetaTypes() {
qRegisterMetaType();
qDBusRegisterMetaType();
qRegisterMetaType>();
qDBusRegisterMetaType>();
}
hud-14.10+17.10.20170619/common/AppstackModel.cpp 0000664 0001750 0001750 00000004315 13121713174 022027 0 ustar didrocks didrocks 0000000 0000000 /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of version 3 of the GNU Lesser General Public License as published
* by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*
* Author: Pete Woods
*/
#include
#include
#include
#include
using namespace hud::common;
const QString APPSTACK_FORMAT_STRING("com.canonical.hud.query%1.appstack");
AppstackModel::AppstackModel(unsigned int id) :
HudDee(APPSTACK_FORMAT_STRING.arg(id).toStdString()) {
setSchema(appstack_model_schema, G_N_ELEMENTS(appstack_model_schema));
}
AppstackModel::~AppstackModel() {
}
static gint appstack_sort(GVariant **row1, GVariant **row2,
gpointer user_data) {
Q_UNUSED(user_data);
gint32 type1 = g_variant_get_int32(row1[HUD_QUERY_APPSTACK_ITEM_TYPE]);
gint32 type2 = g_variant_get_int32(row2[HUD_QUERY_APPSTACK_ITEM_TYPE]);
/* If the types are the same, we'll sort by ID */
if (type1 == type2) {
const gchar * app_id1 = g_variant_get_string(
row1[HUD_QUERY_APPSTACK_APPLICATION_ID], NULL);
const gchar * app_id2 = g_variant_get_string(
row2[HUD_QUERY_APPSTACK_APPLICATION_ID], NULL);
return g_strcmp0(app_id1, app_id2);
}
return type1 - type2;
}
void AppstackModel::addApplication(const QString &applicationId,
const QString &iconName, ItemType itemType) {
GVariant * columns[HUD_QUERY_APPSTACK_COUNT + 1];
columns[HUD_QUERY_APPSTACK_APPLICATION_ID] = g_variant_new_string(
applicationId.toUtf8().data());
columns[HUD_QUERY_APPSTACK_ICON_NAME] = g_variant_new_string(
iconName.toUtf8().data());
columns[HUD_QUERY_APPSTACK_ITEM_TYPE] = g_variant_new_int32(itemType);
columns[HUD_QUERY_APPSTACK_COUNT] = NULL;
insertRowSorted(columns, appstack_sort);
}
hud-14.10+17.10.20170619/common/DBusTypes.cpp 0000664 0001750 0001750 00000004551 13121713174 021164 0 ustar didrocks didrocks 0000000 0000000 /*
* 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
using namespace hud::common;
const QString DBusTypes::HUD_SERVICE_DBUS_NAME("com.canonical.hud");
const QString DBusTypes::HUD_SERVICE_DBUS_PATH("/com/canonical/hud");
const QString DBusTypes::WINDOW_STACK_DBUS_NAME(
"com.canonical.Unity.WindowStack");
const QString DBusTypes::WINDOW_STACK_DBUS_PATH(
"/com/canonical/Unity/WindowStack");
const QString DBusTypes::APPMENU_REGISTRAR_DBUS_NAME(
"com.canonical.AppMenu.Registrar");
const QString DBusTypes::APPMENU_REGISTRAR_DBUS_PATH(
"/com/canonical/AppMenu/Registrar");
const QString DBusTypes::BAMF_DBUS_NAME("org.ayatana.bamf");
const QString DBusTypes::BAMF_MATCHER_DBUS_PATH("/org/ayatana/bamf/matcher");
void DBusTypes::registerMetaTypes() {
NameObject::registerMetaTypes();
Suggestion::registerMetaTypes();
WindowInfo::registerMetaTypes();
Action::registerMetaTypes();
ActionGroup::registerMetaTypes();
Description::registerMetaTypes();
MenuModel::registerMetaTypes();
}
QString DBusTypes::queryPath(unsigned int id) {
return QString("/com/canonical/hud/query/%1").arg(id);
}
QString DBusTypes::applicationPath(const QString &applicationId) {
QString path("/com/canonical/hud/applications/");
for (const unsigned char &c : applicationId.toUtf8()) {
if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
|| (c >= '0' && c <= '9')) {
path.append(c);
} else {
path.append("_");
path.append(QString().sprintf("%02x", c));
}
}
return path;
}
hud-14.10+17.10.20170619/common/MenuModel.cpp 0000664 0001750 0001750 00000002732 13121713174 021166 0 ustar didrocks didrocks 0000000 0000000 /*
* 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
using namespace hud::common;
QDBusArgument & operator<<(QDBusArgument &argument,
const MenuModel &menuModel) {
argument.beginStructure();
argument << QDBusVariant(menuModel.m_variant) << menuModel.m_object;
argument.endStructure();
return argument;
}
const QDBusArgument & operator>>(const QDBusArgument &argument,
MenuModel &menuModel) {
argument.beginStructure();
argument >> menuModel.m_variant >> menuModel.m_object;
argument.endStructure();
return argument;
}
MenuModel::MenuModel() {
}
MenuModel::~MenuModel() {
}
void MenuModel::registerMetaTypes() {
qRegisterMetaType();
qDBusRegisterMetaType();
qRegisterMetaType>();
qDBusRegisterMetaType>();
}
hud-14.10+17.10.20170619/common/Suggestion.cpp 0000664 0001750 0001750 00000007650 13121713174 021434 0 ustar didrocks didrocks 0000000 0000000 /*
* 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;
QDBusArgument & operator<<(QDBusArgument &argument,
const Suggestion &suggestion) {
argument.beginStructure();
argument << suggestion.m_description << suggestion.m_icon
<< suggestion.m_unknown1 << suggestion.m_unknown2
<< suggestion.m_unknown3 << QDBusVariant(suggestion.m_id);
argument.endStructure();
return argument;
}
const QDBusArgument & operator>>(const QDBusArgument &argument,
Suggestion &suggestion) {
argument.beginStructure();
argument >> suggestion.m_description >> suggestion.m_icon
>> suggestion.m_unknown1 >> suggestion.m_unknown2
>> suggestion.m_unknown3 >> suggestion.m_id;
argument.endStructure();
return argument;
}
static void append(QString &result, const QString& input, int start, int end) {
QStringRef substring(input.midRef(start, end));
char *temp = g_markup_escape_text(substring.toUtf8().data(), -1);
result.append(temp);
g_free(temp);
}
/**
* Builds a single line pango formatted description for
* the legacy HUD UI.
*/
static QString buildLegacyHighlights(const QString &input,
const QList> &highlights) {
QString result;
int current(0);
for (const QPair &pair : highlights) {
int start(pair.first);
int stop(pair.second);
// In theory there should be no overlapping, but we
// want to make sure
if (start < current) {
qWarning() << "Overlapping highlighting. At character" << current
<< "and asked to highlight from" << start << "to" << stop;
continue;
}
// Get to the start of the highlight
int initialSkip = start - current;
if (initialSkip > 0) {
append(result, input, current, initialSkip);
}
result.append("");
// Copy the characters in the highlight
int highlightSkip = stop - start;
if (highlightSkip > 0) {
append(result, input, start, highlightSkip);
} else {
qWarning() << "Zero character highlight!";
}
result.append("");
current = stop;
}
int remaining(input.length() - current);
if (remaining > 0) {
append(result, input, current, remaining);
}
return result;
}
Suggestion::Suggestion() {
}
Suggestion::Suggestion(qulonglong id, const QString &commandName,
const QList> &commandHighlights,
const QString &description,
const QList> &descriptionHighlights,
const QString &icon) :
m_icon(icon), m_id(id) {
if (description.isEmpty()) {
m_description = buildLegacyHighlights(commandName, commandHighlights);
} else {
QString cmdHighlights(
buildLegacyHighlights(commandName, commandHighlights));
QString descHighlights(
buildLegacyHighlights(description, descriptionHighlights));
// TRANSLATORS: This is what is shown for Unity7 in
// the HUD entries. %1 is the command name and %2 is a
// description or list of keywords that
// was used to find the entry.
m_description = QString(_("%1\xE2\x80\x82(%2)")).arg(cmdHighlights,
descHighlights);
}
}
Suggestion::~Suggestion() {
}
void Suggestion::registerMetaTypes() {
qRegisterMetaType();
qDBusRegisterMetaType();
qRegisterMetaType>();
qDBusRegisterMetaType>();
}
hud-14.10+17.10.20170619/common/Localisation.h 0000664 0001750 0001750 00000001575 13121713174 021373 0 ustar didrocks didrocks 0000000 0000000 /*
* 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 DAEMON_LOCALISATION_H_
#define DAEMON_LOCALISATION_H_
#include
inline char* _(const char *__msgid) {
return gettext(__msgid);
}
#endif // DAEMON_LOCALISATION_H_
hud-14.10+17.10.20170619/common/Description.cpp 0000664 0001750 0001750 00000003073 13121713174 021563 0 ustar didrocks didrocks 0000000 0000000 /*
* 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
using namespace hud::common;
QDBusArgument & operator<<(QDBusArgument &argument,
const Description &description) {
argument.beginStructure();
argument << description.m_windowId << description.m_context
<< description.m_object;
argument.endStructure();
return argument;
}
const QDBusArgument & operator>>(const QDBusArgument &argument,
Description &description) {
argument.beginStructure();
argument >> description.m_windowId >> description.m_context
>> description.m_object;
argument.endStructure();
return argument;
}
Description::Description() :
m_windowId(0) {
}
Description::~Description() {
}
void Description::registerMetaTypes() {
qRegisterMetaType();
qDBusRegisterMetaType();
qRegisterMetaType>();
qDBusRegisterMetaType>();
}
hud-14.10+17.10.20170619/common/MenuModel.h 0000664 0001750 0001750 00000002511 13121713174 020626 0 ustar didrocks didrocks 0000000 0000000 /*
* 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_COMMON_MENUMODEL_H_
#define HUD_COMMON_MENUMODEL_H_
#include
#include
namespace hud {
namespace common {
class MenuModel {
public:
MenuModel();
virtual ~MenuModel();
static void registerMetaTypes();
//FIXME Give these proper names
QVariant m_variant;
QDBusObjectPath m_object;
};
}
}
Q_DECL_EXPORT
QDBusArgument &operator<<(QDBusArgument &argument,
const hud::common::MenuModel &menuModel);
Q_DECL_EXPORT
const QDBusArgument &operator>>(const QDBusArgument &argument,
hud::common::MenuModel &menuModel);
Q_DECLARE_METATYPE(hud::common::MenuModel)
#endif /* HUD_COMMON_MENUMODEL_H_ */
hud-14.10+17.10.20170619/service/ 0000775 0001750 0001750 00000000000 13121716557 016751 5 ustar didrocks didrocks 0000000 0000000 hud-14.10+17.10.20170619/service/WindowContext.cpp 0000664 0001750 0001750 00000001517 13121713174 022265 0 ustar didrocks didrocks 0000000 0000000 /*
* 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() {
}
hud-14.10+17.10.20170619/service/QueryImpl.h 0000664 0001750 0001750 00000005765 13121713174 021056 0 ustar didrocks didrocks 0000000 0000000 /*
* 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_QUERYIMPL_H_
#define HUD_SERVICE_QUERYIMPL_H_
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
class QueryAdaptor;
namespace hud {
namespace service {
class HudService;
class Q_DECL_EXPORT QueryImpl: public Query, protected QDBusContext {
Q_OBJECT
public:
QueryImpl(unsigned int id, const QString &query, const QString &sender,
EmptyBehaviour emptyBehaviour, HudService &service,
ApplicationList::Ptr applicationList, Voice::Ptr voice,
const QDBusConnection &connection, QObject *parent = 0);
virtual ~QueryImpl();
const QDBusObjectPath & path() const override;
const QList & results() const override;
QString appstackModel() const override;
QString currentQuery() const override;
QString resultsModel() const override;
Q_PROPERTY(QStringList ToolbarItems READ toolbarItems)
QStringList toolbarItems() const override;
public Q_SLOTS:
void CloseQuery();
void ExecuteCommand(const QDBusVariant &item, uint timestamp);
QString ExecuteParameterized(const QDBusVariant &item, uint timestamp,
QString &prefix, QString &baseAction, QDBusObjectPath &actionPath,
QDBusObjectPath &modelPath, int &modelSection);
void ExecuteToolbar(const QString &item, uint timestamp);
int UpdateApp(const QString &app);
int UpdateQuery(const QString &query);
int VoiceQuery(QString &query);
protected Q_SLOTS:
void serviceUnregistered(const QString &service);
void refresh();
protected:
void updateToken(Window::Ptr window);
void notifyPropertyChanged(const QString& interface,
const QString& propertyName);
QScopedPointer m_adaptor;
QDBusConnection m_connection;
QDBusObjectPath m_path;
HudService &m_service;
EmptyBehaviour m_emptyBehaviour;
ApplicationList::Ptr m_applicationList;
Voice::Ptr m_voice;
QString m_query;
QDBusServiceWatcher m_serviceWatcher;
QSharedPointer m_resultsModel;
QSharedPointer m_appstackModel;
QList m_results;
WindowToken::Ptr m_windowToken;
};
}
}
#endif /* HUD_SERVICE_QUERYIMPL_H_ */
hud-14.10+17.10.20170619/service/QGSettingsSearchSettings.cpp 0000664 0001750 0001750 00000003005 13121713174 024342 0 ustar didrocks didrocks 0000000 0000000 /*
* 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
using namespace hud::service;
QGSettingsSearchSettings::QGSettingsSearchSettings() :
m_settings("com.canonical.indicator.appmenu.hud.search",
"/com/canonical/indicator/appmenu/hud/search/") {
connect(&m_settings, SIGNAL(changed(const QString&)), this,
SIGNAL(changed()));
}
QGSettingsSearchSettings::~QGSettingsSearchSettings() {
}
uint QGSettingsSearchSettings::addPenalty() const {
return m_settings.get("addPenalty").toUInt();
}
uint QGSettingsSearchSettings::dropPenalty() const {
return m_settings.get("dropPenalty").toUInt();
}
uint QGSettingsSearchSettings::endDropPenalty() const {
return m_settings.get("endDropPenalty").toUInt();
}
uint QGSettingsSearchSettings::swapPenalty() const {
return m_settings.get("swapPenalty").toUInt();
}
hud-14.10+17.10.20170619/service/Voice.cpp 0000664 0001750 0001750 00000001463 13121713174 020516 0 ustar didrocks didrocks 0000000 0000000 /*
* 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() {
}
hud-14.10+17.10.20170619/service/VoiceImpl.h 0000664 0001750 0001750 00000002120 13121713174 020774 0 ustar didrocks didrocks 0000000 0000000 /*
* 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
*/
#ifndef HUD_SERVICE_VOICEIMPL_H_
#define HUD_SERVICE_VOICEIMPL_H_
#include
namespace hud {
namespace service {
class VoiceImpl: public Voice {
Q_OBJECT
public:
explicit VoiceImpl();
virtual ~VoiceImpl();
QString listen(const QList& commands) override;
private:
};
} // namespace service
} // namespace hud
#endif // HUD_SERVICE_VOICEIMPL_H_
hud-14.10+17.10.20170619/service/ApplicationListImpl.cpp 0000664 0001750 0001750 00000012220 13121713174 023363 0 ustar didrocks didrocks 0000000 0000000 /*
* 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::common;
using namespace hud::service;
static QList IGNORED_APPLICATION_IDS = { "", "compiz", "hud-gui",
"unknown" };
ApplicationListImpl::ApplicationListImpl(Factory &factory,
QSharedPointer windowStack,
QSharedPointer windowStackWatcher) :
m_windowStack(windowStack), m_windowStackWatcher(windowStackWatcher), m_factory(
factory), m_focusedWindowId(0) {
QDBusPendingReply> windowsReply(
m_windowStack->GetWindowStack());
if (windowsReply.isError()) {
qWarning() << windowsReply.error();
return;
}
QList windows(windowsReply);
for (const WindowInfo &window : windows) {
ensureApplicationWithWindow(window.window_id, window.app_id);
if (window.focused) {
//FIXME Stage is wrong
FocusedWindowChanged(window.window_id, window.app_id, 0);
}
}
connect(m_windowStack.data(),
SIGNAL(FocusedWindowChanged(uint, const QString &, uint)), this,
SLOT(FocusedWindowChanged(uint, const QString &, uint)));
connect(m_windowStack.data(),
SIGNAL(WindowCreated(uint, const QString &)), this,
SLOT(WindowCreated(uint, const QString &)));
connect(m_windowStack.data(),
SIGNAL(WindowDestroyed(uint, const QString &)), this,
SLOT(WindowDestroyed(uint, const QString &)));
}
ApplicationListImpl::~ApplicationListImpl() {
}
void ApplicationListImpl::serviceUnregistered(const QString &service) {
Q_UNUSED(service);
m_focusedApplication.reset();
m_applications.clear();
m_focusedWindowId = 0;
}
bool ApplicationListImpl::isIgnoredApplication(const QString &applicationId) {
if (IGNORED_APPLICATION_IDS.contains(applicationId)) {
return true;
}
return false;
}
Application::Ptr ApplicationListImpl::ensureApplication(
const QString &applicationId) {
if (isIgnoredApplication(applicationId)) {
return Application::Ptr();
}
Application::Ptr application(m_applications[applicationId]);
if (application.isNull()) {
application = m_factory.newApplication(applicationId);
m_applications[applicationId] = application;
}
return application;
}
void ApplicationListImpl::ensureApplicationWithWindow(uint windowId,
const QString& applicationId) {
Application::Ptr application(ensureApplication(applicationId));
if (!application.isNull()) {
application->addWindow(windowId);
}
}
void ApplicationListImpl::removeWindow(uint windowId,
const QString& applicationId) {
if (isIgnoredApplication(applicationId)) {
return;
}
Application::Ptr application(m_applications[applicationId]);
if (application.isNull()) {
qWarning() << "Attempt to remove window" << windowId
<< "from non-existent application" << applicationId;
return;
}
application->removeWindow(windowId);
// If the application has no windows left, then the best
// we can do is assume it has been closed.
if (application->isEmpty()) {
m_applications.remove(applicationId);
// If this was the focused application
if (application == m_focusedApplication) {
setFocusedWindow(Application::Ptr(), 0);
}
}
}
void ApplicationListImpl::setFocusedWindow(Application::Ptr application,
uint windowId) {
m_focusedApplication = application;
m_focusedWindowId = windowId;
focusedWindowChanged();
}
void ApplicationListImpl::FocusedWindowChanged(uint windowId,
const QString &applicationId, uint stage) {
Q_UNUSED(stage);
if (isIgnoredApplication(applicationId)) {
return;
}
setFocusedWindow(m_applications[applicationId], windowId);
}
void ApplicationListImpl::WindowCreated(uint windowId,
const QString &applicationId) {
ensureApplicationWithWindow(windowId, applicationId);
}
void ApplicationListImpl::WindowDestroyed(uint windowId,
const QString &applicationId) {
removeWindow(windowId, applicationId);
}
QList ApplicationListImpl::applications() const {
QList results;
for (auto i(m_applications.cbegin()); i != m_applications.cend(); ++i) {
Application::Ptr application(i.value());
if (application) {
results << NameObject(i.key(), application->path());
}
}
return results;
}
Application::Ptr ApplicationListImpl::focusedApplication() const {
return m_focusedApplication;
}
Window::Ptr ApplicationListImpl::focusedWindow() const {
Window::Ptr window;
Application::Ptr application(focusedApplication());
if (!application.isNull()) {
window = application->window(m_focusedWindowId);
}
return window;
}
hud-14.10+17.10.20170619/service/ItemStore.h 0000664 0001750 0001750 00000004741 13121713174 021033 0 ustar didrocks didrocks 0000000 0000000 /*
* 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_ITEMSTORE_H_
#define HUD_SERVICE_ITEMSTORE_H_
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
QT_BEGIN_NAMESPACE
class QDBusObjectPath;
QT_END_NAMESPACE
namespace hud {
namespace service {
class ItemStore: public QObject {
Q_OBJECT
public:
typedef QSharedPointer Ptr;
ItemStore(const QString &applicationId, UsageTracker::Ptr usageTracker,
SearchSettings::Ptr searchSettings);
virtual ~ItemStore();
void indexMenu(const QMenu *menu);
void search(const QString &query, Query::EmptyBehaviour emptyBehaviour,
QList &results);
void execute(unsigned long long commandId);
QString executeParameterized(unsigned long long commandId,
QString &prefix, QString &baseAction, QDBusObjectPath &actionPath,
QDBusObjectPath &modelPath);
void executeToolbar(const QString &item);
QList commands() const;
QStringList toolbarItems() const;
protected Q_SLOTS:
void settingChanged();
protected:
void indexMenu(const QMenu *menu, const QMenu *root,
const QStringList &stack, const QList &index);
void addResult(DocumentID id, const QStringMatcher &stringMatcher,
const int queryLength, const double relevancy,
QList &results);
void executeItem(Item::Ptr item);
Columbus::Corpus m_corpus;
Columbus::Matcher m_matcher;
QString m_applicationId;
UsageTracker::Ptr m_usageTracker;
DocumentID m_nextId;
SearchSettings::Ptr m_settings;
QMap m_items;
QMap m_toolbarItems;
QMap m_mnemonic2DocumentId;
};
}
}
#endif /* HUD_SERVICE_ITEMSTORE_H_ */
hud-14.10+17.10.20170619/service/WindowImpl.cpp 0000664 0001750 0001750 00000007124 13121713174 021542 0 ustar didrocks didrocks 0000000 0000000 /*
* 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
using namespace hud::service;
WindowTokenImpl::WindowTokenImpl(const QList &tokens,
ItemStore::Ptr itemStore) :
m_items(itemStore), m_tokens(tokens) {
m_timer.setSingleShot(true);
connect(&m_timer, SIGNAL(timeout()), this, SIGNAL(changed()));
for (CollectorToken::Ptr token : tokens) {
connect(token.data(), SIGNAL(changed()), this, SLOT(childChanged()));
m_items->indexMenu(token->menu());
}
}
WindowTokenImpl::~WindowTokenImpl() {
}
void WindowTokenImpl::childChanged() {
m_timer.start();
}
const QList & WindowTokenImpl::tokens() const {
return m_tokens;
}
void WindowTokenImpl::search(const QString &query,
Query::EmptyBehaviour emptyBehaviour, QList &results) {
m_items->search(query, emptyBehaviour, results);
}
void WindowTokenImpl::execute(unsigned long long commandId) {
m_items->execute(commandId);
}
QString WindowTokenImpl::executeParameterized(unsigned long long commandId,
QString &prefix, QString &baseAction, QDBusObjectPath &actionPath,
QDBusObjectPath &modelPath) {
return m_items->executeParameterized(commandId, prefix, baseAction,
actionPath, modelPath);
}
void WindowTokenImpl::executeToolbar(const QString &item) {
m_items->executeToolbar(item);
}
QList WindowTokenImpl::commands() const {
return m_items->commands();
}
QStringList WindowTokenImpl::toolbarItems() const {
return m_items->toolbarItems();
}
WindowImpl::WindowImpl(unsigned int windowId, const QString &applicationId,
WindowContext::Ptr allWindowsContext, Factory &factory) :
WindowContextImpl(factory), m_applicationId(applicationId), m_allWindowsContext(
allWindowsContext) {
m_dbusMenuCollector = factory.newDBusMenuWindowCollector(windowId);
m_gMenuCollector = factory.newGMenuWindowCollector(windowId, applicationId);
}
WindowImpl::~WindowImpl() {
}
WindowToken::Ptr WindowImpl::activate() {
WindowToken::Ptr windowToken(m_windowToken);
QList collectors;
collectors << m_dbusMenuCollector << m_gMenuCollector
<< m_allWindowsContext->activeCollector() << activeCollector();
QList tokens;
for (Collector::Ptr collector : collectors) {
if (collector && collector->isValid()) {
tokens.append(collector->activate());
}
}
bool newToken(false);
if (windowToken) {
// If we have an existing token
if (tokens != windowToken->tokens()) {
// If any of the sub-tokens have changed
newToken = true;
}
} else {
// We don't have an existing token
newToken = true;
}
if (newToken) {
windowToken = m_factory.newWindowToken(m_applicationId, tokens);
m_windowToken = windowToken;
connect(this, SIGNAL(contextChanged()), windowToken.data(),
SLOT(childChanged()));
connect(m_allWindowsContext.data(), SIGNAL(contextChanged()),
windowToken.data(), SLOT(childChanged()));
}
return windowToken;
}
hud-14.10+17.10.20170619/service/Collector.cpp 0000664 0001750 0001750 00000002202 13121713174 021367 0 ustar didrocks didrocks 0000000 0000000 /*
* 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;
Collector::Collector(QObject *parent) :
QObject(parent) {
}
Collector::~Collector() {
}
CollectorToken::CollectorToken(Collector::Ptr collector, QMenu *menu) :
m_collector(collector), m_menu(menu) {
}
CollectorToken::~CollectorToken() {
if (Collector::Ptr collector = m_collector.lock()) {
collector->deactivate();
}
}
QMenu * CollectorToken::menu() {
return m_menu;
}
hud-14.10+17.10.20170619/service/DBusMenuWindowCollector.h 0000664 0001750 0001750 00000004036 13121713174 023636 0 ustar didrocks didrocks 0000000 0000000 /*
* 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
*/
#ifndef HUD_SERVICE_DBUSMENUWINDOWCOLLECTOR_H_
#define HUD_SERVICE_DBUSMENUWINDOWCOLLECTOR_H_
#include
class ComCanonicalAppMenuRegistrarInterface;
class ComCanonicalUnityWindowStackInterface;
namespace qtgmenu {
class QtGMenuImporter;
}
namespace hud {
namespace service {
class Factory;
class DBusMenuWindowCollector: public Collector,
public std::enable_shared_from_this {
Q_OBJECT
public:
typedef std::shared_ptr Ptr;
DBusMenuWindowCollector(unsigned int windowId,
QSharedPointer windowStack,
QSharedPointer registrar,
Factory &factory);
virtual ~DBusMenuWindowCollector();
virtual bool isValid() const override;
virtual QList activate() override;
protected Q_SLOTS:
void WindowRegistered(uint windowId, const QString &service,
const QDBusObjectPath &menuObjectPath);
protected:
virtual void deactivate() override;
private:
void windowRegistered(const QString &service,
const QDBusObjectPath &menuObjectPath);
Collector::Ptr m_am_collector;
Collector::Ptr m_collector;
unsigned int m_windowId;
QSharedPointer m_registrar;
Factory &m_factory;
};
}
}
#endif /* HUD_SERVICE_DBUSMENUWINDOWCOLLECTOR_H_ */
hud-14.10+17.10.20170619/service/DBusMenuCollector.h 0000664 0001750 0001750 00000003324 13121713174 022445 0 ustar didrocks didrocks 0000000 0000000 /*
* 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_ */
hud-14.10+17.10.20170619/service/GMenuWindowCollector.h 0000664 0001750 0001750 00000003235 13121713174 023167 0 ustar didrocks didrocks 0000000 0000000 /*
* 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_ */
hud-14.10+17.10.20170619/service/UsageTracker.h 0000664 0001750 0001750 00000002377 13121713174 021503 0 ustar didrocks didrocks 0000000 0000000 /*
* 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_USAGETRACKER_H_
#define HUD_SERVICE_USAGETRACKER_H_
#include
#include
QT_BEGIN_NAMESPACE
class QString;
QT_END_NAMESPACE
namespace hud {
namespace service {
class UsageTracker: public QObject {
public:
typedef QSharedPointer Ptr;
UsageTracker();
virtual ~UsageTracker();
virtual void markUsage(const QString &applicationId,
const QString &entry) = 0;
virtual unsigned int usage(const QString &applicationId,
const QString &entry) const = 0;
};
}
}
#endif /* HUD_SERVICE_USAGETRACKER_H_ */
hud-14.10+17.10.20170619/service/SignalHandler.cpp 0000664 0001750 0001750 00000005240 13121713174 022161 0 ustar didrocks didrocks 0000000 0000000 /*
* 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, Qt::QueuedConnection);
m_socketNotifierTerm = new QSocketNotifier(sigtermFd[1], QSocketNotifier::Read, this);
connect(m_socketNotifierTerm, &QSocketNotifier::activated, this, &SignalHandler::handleSigTerm, Qt::QueuedConnection);
}
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);
}
hud-14.10+17.10.20170619/service/Query.cpp 0000664 0001750 0001750 00000001512 13121713174 020551 0 ustar didrocks didrocks 0000000 0000000 /*
* 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;
Query::Query(QObject *parent) :
QObject(parent) {
}
Query::~Query() {
}
hud-14.10+17.10.20170619/service/ApplicationList.cpp 0000664 0001750 0001750 00000001531 13121713174 022544 0 ustar didrocks didrocks 0000000 0000000 /*
* 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() {
}
hud-14.10+17.10.20170619/service/Voice.h 0000664 0001750 0001750 00000002320 13121713174 020154 0 ustar didrocks didrocks 0000000 0000000 /*
* 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
*/
#ifndef HUD_SERVICE_VOICE_H_
#define HUD_SERVICE_VOICE_H_
#include
#include
namespace hud {
namespace service {
class ItemStore;
class Voice: public QObject {
Q_OBJECT
public:
explicit Voice();
virtual ~Voice();
virtual QString listen(const QList& commands) = 0;
Q_SIGNALS:
void HeardSomething();
void Listening();
void Loading();
public:
using Ptr = QSharedPointer< Voice >;
};
} // namespace service
} // namespace hud
#endif // HUD_SERVICE_VOICE_H_
hud-14.10+17.10.20170619/service/GMenuWindowCollector.cpp 0000664 0001750 0001750 00000006551 13121713174 023526 0 ustar didrocks didrocks 0000000 0000000 /*
* 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