Back to index

unity  6.0.0
Public Member Functions | Static Public Member Functions | Public Attributes
unity::dash::Lens::Impl Class Reference
Collaboration diagram for unity::dash::Lens::Impl:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 ~Impl ()
void OnProxyConnectionChanged ()
void OnProxyDisconnected ()
void ResultsModelUpdated (unsigned long long begin_seqnum, unsigned long long end_seqnum)
void GlobalResultsModelUpdated (unsigned long long begin_seqnum, unsigned long long end_seqnum)
unsigned long long ExtractModelSeqnum (GVariant *parameters)
void OnSearchFinished (GVariant *parameters)
void OnGlobalSearchFinished (GVariant *parameters)
void OnChanged (GVariant *parameters)
void UpdateProperties (bool search_in_global, bool visible, string const &search_hint, string const &private_connection_name, string const &results_model_name, string const &global_results_model_name, string const &categories_model_name, string const &filters_model_name)
void OnViewTypeChanged (ViewType view_type)
void GlobalSearch (std::string const &search_string)
void Search (std::string const &search_string)
void Activate (std::string const &uri)
void ActivationReply (GVariant *parameters)
void Preview (std::string const &uri)
void PreviewReply (GVariant *parameters)
string const & id () const
string const & dbus_name () const
string const & dbus_path () const
string const & name () const
string const & icon_hint () const
string const & description () const
string const & search_hint () const
bool visible () const
bool search_in_global () const
bool set_search_in_global (bool val)
string const & shortcut () const
Results::Ptr const & results () const
Results::Ptr const & global_results () const
Categories::Ptr const & categories () const
Filters::Ptr const & filters () const
bool connected () const

Static Public Member Functions

 Impl (Lens *owner, string const &id, string const &dbus_name, string const &dbus_path, string const &name, string const &icon_hint, string const &description, string const &search_hint, bool visible, string const &shortcut, ModelType model_type)

Public Attributes

Lensowner_
string id_
string dbus_name_
string dbus_path_
string name_
string icon_hint_
string description_
string search_hint_
bool visible_
bool search_in_global_
string shortcut_
Results::Ptr results_
Results::Ptr global_results_
Categories::Ptr categories_
Filters::Ptr filters_
bool connected_
string private_connection_name_
glib::DBusProxyproxy_
glib::Object< GCancellable > search_cancellable_
glib::Object< GCancellable > global_search_cancellable_
GVariant * results_variant_
GVariant * global_results_variant_

Detailed Description

Definition at line 42 of file Lens.cpp.


Constructor & Destructor Documentation

unity::dash::Lens::Impl::Impl ( Lens owner,
string const &  id,
string const &  dbus_name,
string const &  dbus_path,
string const &  name,
string const &  icon_hint,
string const &  description,
string const &  search_hint,
bool  visible,
string const &  shortcut,
ModelType  model_type 
) [static]

Definition at line 134 of file Lens.cpp.

  : owner_(owner)
  , id_(id)
  , dbus_name_(dbus_name)
  , dbus_path_(dbus_path)
  , name_(name)
  , icon_hint_(icon_hint)
  , description_(description)
  , search_hint_(search_hint)
  , visible_(visible)
  , search_in_global_(false)
  , shortcut_(shortcut)
  , results_(new Results(model_type))
  , global_results_(new Results(model_type))
  , categories_(new Categories(model_type))
  , filters_(new Filters(model_type))
  , connected_(false)
  , proxy_(NULL)
  , results_variant_(NULL)
  , global_results_variant_(NULL)
{
  if (model_type == ModelType::REMOTE)
  {
    proxy_ = new glib::DBusProxy(dbus_name, dbus_path, "com.canonical.Unity.Lens");
    proxy_->connected.connect(sigc::mem_fun(this, &Lens::Impl::OnProxyConnectionChanged));
    proxy_->disconnected.connect(sigc::mem_fun(this, &Lens::Impl::OnProxyDisconnected));
    proxy_->Connect("Changed", sigc::mem_fun(this, &Lens::Impl::OnChanged));
  }

  /* Technically these signals will only be fired by remote models, but we
   * connect them no matter the ModelType. Dee may grow support in the future.
   */
  results_->end_transaction.connect(sigc::mem_fun(this, &Lens::Impl::ResultsModelUpdated));
  global_results_->end_transaction.connect(sigc::mem_fun(this, &Lens::Impl::GlobalResultsModelUpdated));

  owner_->id.SetGetterFunction(sigc::mem_fun(this, &Lens::Impl::id));
  owner_->dbus_name.SetGetterFunction(sigc::mem_fun(this, &Lens::Impl::dbus_name));
  owner_->dbus_path.SetGetterFunction(sigc::mem_fun(this, &Lens::Impl::dbus_path));
  owner_->name.SetGetterFunction(sigc::mem_fun(this, &Lens::Impl::name));
  owner_->icon_hint.SetGetterFunction(sigc::mem_fun(this, &Lens::Impl::icon_hint));
  owner_->description.SetGetterFunction(sigc::mem_fun(this, &Lens::Impl::description));
  owner_->search_hint.SetGetterFunction(sigc::mem_fun(this, &Lens::Impl::search_hint));
  owner_->visible.SetGetterFunction(sigc::mem_fun(this, &Lens::Impl::visible));
  owner_->search_in_global.SetGetterFunction(sigc::mem_fun(this, &Lens::Impl::search_in_global));
  owner_->search_in_global.SetSetterFunction(sigc::mem_fun(this, &Lens::Impl::set_search_in_global));
  owner_->shortcut.SetGetterFunction(sigc::mem_fun(this, &Lens::Impl::shortcut));
  owner_->results.SetGetterFunction(sigc::mem_fun(this, &Lens::Impl::results));
  owner_->global_results.SetGetterFunction(sigc::mem_fun(this, &Lens::Impl::global_results));
  owner_->categories.SetGetterFunction(sigc::mem_fun(this, &Lens::Impl::categories));
  owner_->filters.SetGetterFunction(sigc::mem_fun(this, &Lens::Impl::filters));
  owner_->connected.SetGetterFunction(sigc::mem_fun(this, &Lens::Impl::connected));
  owner_->view_type.changed.connect(sigc::mem_fun(this, &Lens::Impl::OnViewTypeChanged));
}

Here is the call graph for this function:

Definition at line 198 of file Lens.cpp.

{
  if (search_cancellable_)
  {
    g_cancellable_cancel (search_cancellable_);
  }
  if (global_search_cancellable_)
  {
    g_cancellable_cancel (global_search_cancellable_);
  }

  if (proxy_)
    delete proxy_;
}

Member Function Documentation

void unity::dash::Lens::Impl::Activate ( std::string const &  uri)

Definition at line 487 of file Lens.cpp.

{
  LOG_DEBUG(logger) << "Activating '" << uri << "' on  '" << id_ << "'";

  if (!proxy_->IsConnected())
    {
      LOG_DEBUG(logger) << "Skipping activation. Proxy not connected. ('" << id_ << "')";
      return;
    }

  proxy_->Call("Activate",
               g_variant_new("(su)", uri.c_str(), 0),
               sigc::mem_fun(this, &Lens::Impl::ActivationReply));
}

Here is the call graph for this function:

Here is the caller graph for this function:

void unity::dash::Lens::Impl::ActivationReply ( GVariant *  parameters)

Definition at line 502 of file Lens.cpp.

{
  glib::String uri;
  guint32 handled;
  GVariant* hints_variant;
  Hints hints;
  
  g_variant_get(parameters, "((su@a{sv}))", &uri, &handled, &hints_variant);

  glib::Variant dict (hints_variant, glib::StealRef());
  dict.ASVToHints(hints);

  owner_->activated.emit(uri.Str(), static_cast<HandledType>(handled), hints);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 618 of file Lens.cpp.

{
  return categories_;
}

Here is the caller graph for this function:

Definition at line 628 of file Lens.cpp.

{
  return connected_;
}

Here is the caller graph for this function:

string const & unity::dash::Lens::Impl::dbus_name ( ) const

Definition at line 552 of file Lens.cpp.

{
  return dbus_name_;
}

Here is the caller graph for this function:

string const & unity::dash::Lens::Impl::dbus_path ( ) const

Definition at line 557 of file Lens.cpp.

{
  return dbus_path_;
}

Here is the caller graph for this function:

string const & unity::dash::Lens::Impl::description ( ) const

Definition at line 572 of file Lens.cpp.

{
  return description_;
}

Here is the caller graph for this function:

unsigned long long unity::dash::Lens::Impl::ExtractModelSeqnum ( GVariant *  parameters)

Definition at line 263 of file Lens.cpp.

{
  GVariant *dict;
  guint64 seqnum64;
  unsigned long long seqnum = 0;

  dict = g_variant_get_child_value (parameters, 0);
  if (dict)
  {
    if (g_variant_lookup (dict, "model-seqnum", "t", &seqnum64))
    {
      seqnum = static_cast<unsigned long long> (seqnum64);
    }

    g_variant_unref (dict);
  }

  return seqnum;
}

Definition at line 623 of file Lens.cpp.

{
  return filters_;
}

Here is the caller graph for this function:

Definition at line 613 of file Lens.cpp.

{
  return global_results_;
}

Here is the caller graph for this function:

void unity::dash::Lens::Impl::GlobalResultsModelUpdated ( unsigned long long  begin_seqnum,
unsigned long long  end_seqnum 
)

Definition at line 246 of file Lens.cpp.

{
  if (global_results_variant_ != NULL &&
      end_seqnum >= ExtractModelSeqnum (global_results_variant_))
  {
    glib::Variant dict(global_results_variant_, glib::StealRef());
    Hints hints;

    dict.ASVToHints(hints);

    owner_->global_search_finished.emit(hints);

    global_results_variant_ = NULL;
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void unity::dash::Lens::Impl::GlobalSearch ( std::string const &  search_string)

Definition at line 429 of file Lens.cpp.

{
  LOG_DEBUG(logger) << "Global Searching '" << id_ << "' for '" << search_string << "'";

  GVariantBuilder b;
  g_variant_builder_init(&b, G_VARIANT_TYPE("a{sv}"));

  if (global_search_cancellable_)
    g_cancellable_cancel (global_search_cancellable_);
  global_search_cancellable_ = g_cancellable_new ();

  if (global_results_variant_)
  {
    g_variant_unref (global_results_variant_);
    global_results_variant_ = NULL;
  }

  proxy_->Call("GlobalSearch",
              g_variant_new("(sa{sv})",
                            search_string.c_str(),
                            &b),
              sigc::mem_fun(this, &Lens::Impl::OnGlobalSearchFinished),
              global_search_cancellable_);
  g_variant_builder_clear(&b);
}

Here is the call graph for this function:

Here is the caller graph for this function:

string const & unity::dash::Lens::Impl::icon_hint ( ) const

Definition at line 567 of file Lens.cpp.

{
  return icon_hint_;
}

Here is the caller graph for this function:

string const & unity::dash::Lens::Impl::id ( ) const

Definition at line 547 of file Lens.cpp.

{
  return id_;
}

Here is the caller graph for this function:

string const & unity::dash::Lens::Impl::name ( ) const

Definition at line 562 of file Lens.cpp.

{
  return name_;
}

Here is the caller graph for this function:

void unity::dash::Lens::Impl::OnChanged ( GVariant *  parameters)

Definition at line 327 of file Lens.cpp.

{
  glib::String dbus_path;
  gboolean search_in_global = FALSE;
  gboolean visible = FALSE;
  glib::String search_hint;
  glib::String private_connection_name;
  glib::String results_model_name;
  glib::String global_results_model_name;
  glib::String categories_model_name;
  glib::String filters_model_name;
  GVariantIter* hints_iter = NULL;

  g_variant_get(parameters, "((sbbssssssa{sv}))",
                &dbus_path,
                &search_in_global,
                &visible,
                &search_hint,
                &private_connection_name,
                &results_model_name,
                &global_results_model_name,
                &categories_model_name,
                &filters_model_name,
                &hints_iter);

  LOG_DEBUG(logger) << "Lens info changed for " << name_ << "\n"
                    << "  Path: " << dbus_path << "\n"
                    << "  SearchInGlobal: " << search_in_global << "\n"
                    << "  Visible: " << visible << "\n"
                    << "  PrivateConnName: " << private_connection_name << "\n"
                    << "  Results: " << results_model_name << "\n"
                    << "  GlobalModel: " << global_results_model_name << "\n"
                    << "  Categories: " << categories_model_name << "\n"
                    << "  Filters: " << filters_model_name << "\n";
  if (dbus_path.Str() == dbus_path_)
  {
    /* FIXME: We ignore hints for now */
    UpdateProperties(search_in_global,
                     visible,
                     search_hint.Str(),
                     private_connection_name.Str(),
                     results_model_name.Str(),
                     global_results_model_name.Str(),
                     categories_model_name.Str(),
                     filters_model_name.Str());
  }
  else
  {
    LOG_WARNING(logger) << "Paths do not match " << dbus_path_ << " != " << dbus_path;
  }

  connected_ = true;
  owner_->connected.EmitChanged(connected_);

  g_variant_iter_free(hints_iter);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void unity::dash::Lens::Impl::OnGlobalSearchFinished ( GVariant *  parameters)

Definition at line 305 of file Lens.cpp.

{
  Hints hints;
  unsigned long long reply_seqnum;
  
  reply_seqnum = ExtractModelSeqnum (parameters);
  if (global_results_->seqnum < reply_seqnum)
  {
    // wait for the end-transaction signal
    if (global_results_variant_) g_variant_unref (global_results_variant_);
    global_results_variant_ = g_variant_ref (parameters);

    // GlobalResultsModelUpdated will emit OnGlobalSearchFinished
    return;
  }

  glib::Variant dict (parameters);
  dict.ASVToHints(hints);

  owner_->global_search_finished.emit(hints);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 213 of file Lens.cpp.

{
  if (proxy_->IsConnected())
  {
    proxy_->Call("InfoRequest");
    ViewType current_view_type = owner_->view_type;
    proxy_->Call("SetViewType", g_variant_new("(u)", current_view_type));
  }
}

Here is the caller graph for this function:

Definition at line 223 of file Lens.cpp.

{
  connected_ = false;
  owner_->connected.EmitChanged(connected_);
}

Here is the caller graph for this function:

void unity::dash::Lens::Impl::OnSearchFinished ( GVariant *  parameters)

Definition at line 283 of file Lens.cpp.

{
  Hints hints;
  unsigned long long reply_seqnum;

  reply_seqnum = ExtractModelSeqnum (parameters);
  if (results_->seqnum < reply_seqnum)
  {
    // wait for the end-transaction signal
    if (results_variant_) g_variant_unref (results_variant_);
    results_variant_ = g_variant_ref (parameters);

    // ResultsModelUpdated will emit OnSearchFinished
    return;
  }

  glib::Variant dict (parameters);
  dict.ASVToHints(hints);

  owner_->search_finished.emit(hints);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 423 of file Lens.cpp.

{
  if (proxy_ && proxy_->IsConnected())
    proxy_->Call("SetViewType", g_variant_new("(u)", view_type));
}

Here is the caller graph for this function:

void unity::dash::Lens::Impl::Preview ( std::string const &  uri)

Definition at line 517 of file Lens.cpp.

{
  LOG_DEBUG(logger) << "Previewing '" << uri << "' on  '" << id_ << "'";

  if (!proxy_->IsConnected())
    {
      LOG_DEBUG(logger) << "Skipping preview. Proxy not connected. ('" << id_ << "')";
      return;
    }

  proxy_->Call("Preview",
               g_variant_new("(s)", uri.c_str()),
               sigc::mem_fun(this, &Lens::Impl::PreviewReply));
}

Here is the call graph for this function:

Here is the caller graph for this function:

void unity::dash::Lens::Impl::PreviewReply ( GVariant *  parameters)

Definition at line 532 of file Lens.cpp.

{
  glib::String uri;
  glib::String renderer_name;
  GVariant* hints_variant;
  Hints hints;
  
  g_variant_get(parameters, "((ss@a{sv}))", &uri, &renderer_name, &hints_variant);

  glib::Variant dict (hints_variant, glib::StealRef());
  dict.ASVToHints(hints);

  Preview::Ptr preview = Preview::PreviewForProperties(renderer_name.Str(), hints);
  owner_->preview_ready.emit(uri.Str(), preview);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 608 of file Lens.cpp.

{
  return results_;
}

Here is the caller graph for this function:

void unity::dash::Lens::Impl::ResultsModelUpdated ( unsigned long long  begin_seqnum,
unsigned long long  end_seqnum 
)

Definition at line 229 of file Lens.cpp.

{
  if (results_variant_ != NULL &&
      end_seqnum >= ExtractModelSeqnum (results_variant_))
  {
    glib::Variant dict(results_variant_, glib::StealRef());
    Hints hints;

    dict.ASVToHints(hints);

    owner_->search_finished.emit(hints);

    results_variant_ = NULL;
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void unity::dash::Lens::Impl::Search ( std::string const &  search_string)

Definition at line 455 of file Lens.cpp.

{
  LOG_DEBUG(logger) << "Searching '" << id_ << "' for '" << search_string << "'";

  if (proxy_ == NULL)
  {
    LOG_DEBUG(logger) << "Skipping search. Proxy not initialized. ('" << id_ << "')";
    return;
  }

  GVariantBuilder b;
  g_variant_builder_init(&b, G_VARIANT_TYPE("a{sv}"));

  if (search_cancellable_) g_cancellable_cancel (search_cancellable_);
  search_cancellable_ = g_cancellable_new ();

  if (results_variant_)
  {
    g_variant_unref (results_variant_);
    results_variant_ = NULL;
  }

  proxy_->Call("Search",
               g_variant_new("(sa{sv})",
                             search_string.c_str(),
                             &b),
               sigc::mem_fun(this, &Lens::Impl::OnSearchFinished),
               search_cancellable_);

  g_variant_builder_clear(&b);
}

Here is the call graph for this function:

Here is the caller graph for this function:

string const & unity::dash::Lens::Impl::search_hint ( ) const

Definition at line 577 of file Lens.cpp.

{
  return search_hint_;
}

Here is the caller graph for this function:

Definition at line 587 of file Lens.cpp.

{
  return search_in_global_;
}

Here is the caller graph for this function:

Definition at line 592 of file Lens.cpp.

{
  if (search_in_global_ != val)
  {
    search_in_global_ = val;
    owner_->search_in_global.EmitChanged(val);
  }

  return search_in_global_;
}

Here is the caller graph for this function:

string const & unity::dash::Lens::Impl::shortcut ( ) const

Definition at line 603 of file Lens.cpp.

{
  return shortcut_;
}

Here is the caller graph for this function:

void unity::dash::Lens::Impl::UpdateProperties ( bool  search_in_global,
bool  visible,
string const &  search_hint,
string const &  private_connection_name,
string const &  results_model_name,
string const &  global_results_model_name,
string const &  categories_model_name,
string const &  filters_model_name 
)

Definition at line 384 of file Lens.cpp.

{
  // Diff the properties received from those we have
  if (search_hint_ != search_hint)
  {
    search_hint_ = search_hint;
    owner_->search_hint.EmitChanged(search_hint_);
  }

  if (search_in_global_ != search_in_global)
  {
    search_in_global_ = search_in_global;
    owner_->search_in_global.EmitChanged(search_in_global_);
  }

  if (visible_ != visible)
  {
    visible_ = visible;
    owner_->visible.EmitChanged(visible_);
  }

  if (private_connection_name_ != private_connection_name)
  {
    // FIXME: Update all the models as they are no longer valid when we use this
    private_connection_name_ = private_connection_name;
  }
  categories_->swarm_name = categories_model_name;
  filters_->swarm_name = filters_model_name;
  global_results_->swarm_name = global_results_model_name;
  results_->swarm_name = results_model_name;
}

Definition at line 582 of file Lens.cpp.

{
  return visible_;
}

Here is the caller graph for this function:


Member Data Documentation

Definition at line 120 of file Lens.cpp.

Definition at line 122 of file Lens.cpp.

Definition at line 109 of file Lens.cpp.

Definition at line 110 of file Lens.cpp.

Definition at line 113 of file Lens.cpp.

Definition at line 121 of file Lens.cpp.

Definition at line 119 of file Lens.cpp.

Definition at line 131 of file Lens.cpp.

Definition at line 128 of file Lens.cpp.

Definition at line 112 of file Lens.cpp.

Definition at line 108 of file Lens.cpp.

Definition at line 111 of file Lens.cpp.

Definition at line 106 of file Lens.cpp.

Definition at line 124 of file Lens.cpp.

Definition at line 126 of file Lens.cpp.

Definition at line 118 of file Lens.cpp.

Definition at line 130 of file Lens.cpp.

Definition at line 127 of file Lens.cpp.

Definition at line 114 of file Lens.cpp.

Definition at line 116 of file Lens.cpp.

Definition at line 117 of file Lens.cpp.

Definition at line 115 of file Lens.cpp.


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