#!/usr/bin/env python
#
# telepathy-pinocchio - dummy Telepathy connection manager for instrumentation
#
# Copyright (C) 2008 Nokia Corporation
# Copyright (C) 2008 Collabora Ltd.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public License
# version 2.1 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 library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
# 02110-1301 USA

import gobject
from dbus.mainloop.glib import DBusGMainLoop

import pinocchio as pin

TIMEOUT_MS = 3000

def assert_cm_connections(mainloop, manager):
    if len(manager._connections) <= 0:
        mainloop.quit()

    # never automatically destroy this timeout
    return True

if __name__ == '__main__':
    DBusGMainLoop(set_as_default=True)

    manager = pin.ConnectionManager()
    mainloop = gobject.MainLoop()
    gobject.timeout_add(TIMEOUT_MS, assert_cm_connections, mainloop, manager)

    mainloop.run()
