Back to index

unity  6.0.0
StartupNotifyService.cpp
Go to the documentation of this file.
00001 // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
00002 /*
00003  * Copyright (C) 2010 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: Jason Smith <jason.smith@canonical.com>
00018  */
00019 
00020 #include "StartupNotifyService.h"
00021 #include <stdio.h>
00022 
00023 StartupNotifyService* StartupNotifyService::_default = 0;
00024 
00025 StartupNotifyService*
00026 StartupNotifyService::Default()
00027 {
00028   if (!_default)
00029     _default = new StartupNotifyService();
00030 
00031   return _default;
00032 }
00033 
00034 StartupNotifyService::StartupNotifyService()
00035 {
00036 }
00037 
00038 StartupNotifyService::~StartupNotifyService()
00039 {
00040 }
00041 
00042 void
00043 StartupNotifyService::OnMonitorEvent(SnMonitorEvent* sn_event, void* user_data)
00044 {
00045   StartupNotifyService* service = (StartupNotifyService*) user_data;
00046   SnStartupSequence* seq;
00047   const char* id;
00048 
00049   seq = sn_monitor_event_get_startup_sequence(sn_event);
00050   id = sn_startup_sequence_get_id(seq);
00051 
00052   switch (sn_monitor_event_get_type(sn_event))
00053   {
00054     case SN_MONITOR_EVENT_INITIATED:
00055       service->StartupInitiated.emit(id);
00056       break;
00057     case SN_MONITOR_EVENT_COMPLETED:
00058       service->StartupCompleted.emit(id);
00059       break;
00060     default:
00061       break;
00062   }
00063 
00064 }
00065 
00066 void
00067 StartupNotifyService::SetSnDisplay(SnDisplay* sn_display, int screen)
00068 {
00069   _sn_display = sn_display;
00070   _sn_monitor = sn_monitor_context_new(_sn_display, screen, &StartupNotifyService::OnMonitorEvent, this, NULL);
00071 }