Back to index

unity  6.0.0
LauncherEntryRemoteModel.h
Go to the documentation of this file.
00001 // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
00002 /*
00003  * Copyright (C) 2011 Canonical Ltd
00004  *
00005  * This program is free software: you can redistribute it and/or modify
00006  * it under the terms of the GNU General Public License version 3 as
00007  * published by the Free Software Foundation.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00016  *
00017  * Authored by: Mikkel Kamstrup Erlandsen <mikkel.kamstrup@canonical.com>
00018  */
00019 
00020 #ifndef LAUNCHER_ENTRY_REMOTE_MODEL_H
00021 #define LAUNCHER_ENTRY_REMOTE_MODEL_H
00022 
00023 #include <gio/gio.h>
00024 #include <sigc++/sigc++.h>
00025 #include <map>
00026 
00027 #include "LauncherEntryRemote.h"
00028 
00029 namespace unity
00030 {
00031 
00032 class LauncherEntryRemoteModel : public sigc::trackable
00033 {
00034 public:
00035   LauncherEntryRemoteModel();
00036   ~LauncherEntryRemoteModel();
00037 
00038   unsigned int Size() const;
00039   LauncherEntryRemote::Ptr LookupByUri(std::string const& app_uri);
00040   LauncherEntryRemote::Ptr LookupByDesktopId(std::string const& desktop_id);
00041   LauncherEntryRemote::Ptr LookupByDesktopFile(std::string const& desktop_file_path);
00042   std::list<std::string> GetUris() const;
00043 
00044   sigc::signal<void, LauncherEntryRemote::Ptr const&> entry_added;
00045   sigc::signal<void, LauncherEntryRemote::Ptr const&> entry_removed;
00046 
00047 private:
00048   void AddEntry(LauncherEntryRemote::Ptr const& entry);
00049   void RemoveEntry(LauncherEntryRemote::Ptr const& entry);
00050   void HandleUpdateRequest(std::string const& sender_name, GVariant* paramaters);
00051 
00052   static void OnEntrySignalReceived(GDBusConnection* connection,
00053                                     const gchar* sender_name,
00054                                     const gchar* object_path,
00055                                     const gchar* interface_name,
00056                                     const gchar* signal_name,
00057                                     GVariant* parameters,
00058                                     gpointer user_data);
00059 
00060   static void OnDBusNameOwnerChanged(GDBusConnection* connection,
00061                                      const gchar* sender_name,
00062                                      const gchar* object_path,
00063                                      const gchar* interface_name,
00064                                      const gchar* signal_name,
00065                                      GVariant* parameters,
00066                                      gpointer user_data);
00067 
00068   glib::Object<GDBusConnection> _conn;
00069   unsigned int _launcher_entry_dbus_signal_id;
00070   unsigned int _dbus_name_owner_changed_signal_id;
00071   std::map<std::string, LauncherEntryRemote::Ptr> _entries_by_uri;
00072 };
00073 
00074 } // namespace
00075 #endif // LAUNCHER_ENTRY_REMOTE_MODEL_H