#!/usr/bin/python
# -*- coding: utf-8 -*-
'''
Copyright (c) 2012, Tarek Galal <tarek@wazapp.im>

This file is part of Wazapp, an IM application for Meego Harmattan platform that
 allows communication with Whatsapp users

Wazapp is free software: you can redistribute it and/or modify it under the 
terms of the GNU General Public License as published by the Free Software 
Foundation, either version 2 of the License, or (at your option) any later 
version.

Wazapp 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 General Public License for more details.

You should have received a copy of the GNU General Public License along with 
Wazapp. If not, see http://www.gnu.org/licenses/.
'''
import os,dbus,sys

if __name__=="__main__":
	try:
		bus = dbus.SessionBus()
		remote_object = bus.get_object("com.tgalal.meego.Wazapp.WAService", "/")
		print "FOUND RUNNING INSTANCE"
		remote_object.show();
		sys.exit();
	except dbus.exceptions.DBusException as e:
		print "CAUGHT EXCEPT"
		os.system("exec /usr/bin/invoker --type=e --splash /opt/waxmppplugin/bin/wazapp/UI/common/images/splash/wasplash.png /opt/waxmppplugin/bin/wazapp/wazapp"); #logging cause incoming messages not receiving
		#os.system("exec /usr/bin/invoker --type=e --splash /opt/waxmppplugin/bin/wazapp/UI/common/images/splash/wasplash.png /opt/waxmppplugin/bin/wazapp/wazapp > /home/user/walogs 2>&1");
	

	
	
	
		
