Back to index

unity  6.0.0
Public Member Functions | Static Public Member Functions | Public Attributes
unity::hud::HudImpl Class Reference
Collaboration diagram for unity::hud::HudImpl:
Collaboration graph
[legend]

List of all members.

Public Member Functions

void QueryCallback (GVariant *data)
void UpdateQueryCallback (GVariant *data)
void BuildQueries (GVariant *query_array)
void ExecuteByKey (GVariant *key, unsigned int timestamp)
void ExecuteQueryByStringCallback (GVariant *query, unsigned int timestamp)
void CloseQuery ()

Static Public Member Functions

 HudImpl (std::string const &dbus_name, std::string const &dbus_path, Hud *parent)

Public Attributes

GVariant * query_key_
Hud::Queries queries_
glib::DBusProxy proxy_
Hudparent_

Detailed Description

Definition at line 44 of file Hud.cpp.


Constructor & Destructor Documentation

unity::hud::HudImpl::HudImpl ( std::string const &  dbus_name,
std::string const &  dbus_path,
Hud parent 
) [inline, static]

Definition at line 47 of file Hud.cpp.

  : query_key_(NULL)
  , proxy_(dbus_name, dbus_path, "com.canonical.hud")
  , parent_(parent)
  {
    LOG_DEBUG(logger) << "Hud init with name: " << dbus_name << "and path: " << dbus_path;
    proxy_.connected.connect([&]() {
      LOG_DEBUG(logger) << "Hud Connected";
      parent_->connected = true;
    });

    proxy_.Connect("UpdatedQuery", sigc::mem_fun(this, &HudImpl::UpdateQueryCallback));
  }

Here is the call graph for this function:


Member Function Documentation

void unity::hud::HudImpl::BuildQueries ( GVariant *  query_array)

Definition at line 158 of file Hud.cpp.

{
  GVariantIter iter;
  g_variant_iter_init(&iter, query_array);
  gchar* formatted_text;
  gchar* icon;
  gchar* item_icon;
  gchar* completion_text;
  gchar* shortcut;
  GVariant* key = NULL;

  while (g_variant_iter_loop(&iter, "(sssssv)",
         &formatted_text, &icon, &item_icon, &completion_text, &shortcut, &key))
  {
    queries_.push_back(Query::Ptr(new Query(formatted_text,
                                            icon,
                                            item_icon,
                                            completion_text,
                                            shortcut,
                                            key)));
  }
}

Here is the caller graph for this function:

Definition at line 181 of file Hud.cpp.

{
  if (query_key_ == NULL)
  {
    LOG_WARN(logger) << "Attempted to close the hud connection without starting it";
  }
  else
  {
    GVariant* paramaters = g_variant_new("(v)", query_key_);
    proxy_.Call("CloseQuery", paramaters);
    g_variant_unref(query_key_);
    query_key_ = NULL;
    queries_.clear();
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void unity::hud::HudImpl::ExecuteByKey ( GVariant *  key,
unsigned int  timestamp 
)

Definition at line 76 of file Hud.cpp.

{
  LOG_DEBUG(logger) << "Executing by Key";

  GVariantBuilder tuple;
  g_variant_builder_init(&tuple, G_VARIANT_TYPE_TUPLE);
  g_variant_builder_add_value(&tuple, g_variant_new_variant(key));
  g_variant_builder_add_value(&tuple, g_variant_new_uint32(timestamp));

  proxy_.Call("ExecuteQuery", g_variant_builder_end(&tuple));
}

Here is the call graph for this function:

Here is the caller graph for this function:

void unity::hud::HudImpl::ExecuteQueryByStringCallback ( GVariant *  query,
unsigned int  timestamp 
)

Definition at line 88 of file Hud.cpp.

{
  if (g_variant_n_children(query) < 3)
  {
    LOG_ERROR(logger) << "Received (" << g_variant_n_children(query) << ") children in a query, expected 3";
    return;
  }

  queries_.clear();

  GVariant* query_key = g_variant_get_child_value(query, 2);
  query_key_ = query_key;

  GVariant* queries = g_variant_get_child_value(query, 1);
  BuildQueries(queries);
  g_variant_unref(queries);

  if (queries_.empty() == false)
  {
    // we now execute based off the first result
    ExecuteByKey(queries_.front()->key, timestamp);
    CloseQuery();
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void unity::hud::HudImpl::QueryCallback ( GVariant *  data)

Definition at line 113 of file Hud.cpp.

{
  if (g_variant_n_children(query) < 3)
  {
    LOG_ERROR(logger) << "Received (" << g_variant_n_children(query) << ") children in a query, expected 3";
    return;
  }
  queries_.clear();

  // extract the information from the GVariants
  GVariant* target = g_variant_get_child_value(query, 0);
  g_variant_unref(target);

  GVariant* query_key = g_variant_get_child_value(query, 2);
  query_key_ = query_key;

  GVariant* queries = g_variant_get_child_value(query, 1);
  BuildQueries(queries);
  g_variant_unref(queries);

  parent_->queries_updated.emit(queries_);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void unity::hud::HudImpl::UpdateQueryCallback ( GVariant *  data)

Definition at line 136 of file Hud.cpp.

{
  if (g_variant_n_children(query) < 3)
  {
    LOG_ERROR(logger) << "Received (" << g_variant_n_children(query) << ") children in a query, expected 3";
    return;
  }
  // as we are expecting an update, we want to check
  // and make sure that we are the actual receivers of
  // the signal

  GVariant* query_key = g_variant_get_child_value(query, 2);
  if (query_key_ && g_variant_equal(query_key_, query_key))
  {
    queries_.clear();
    GVariant* queries = g_variant_get_child_value(query, 1);
    BuildQueries(queries);
    g_variant_unref(queries);
    parent_->queries_updated.emit(queries_);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 73 of file Hud.cpp.

Definition at line 72 of file Hud.cpp.

Definition at line 71 of file Hud.cpp.

Definition at line 70 of file Hud.cpp.


The documentation for this class was generated from the following file: