Sat, 27 Aug 2016 18:16:01 -0500
connection: Add purple_connection_take_error()
This patch adds a purple_connection_take_error() function, which
is functionally equivalent to purple_connection_g_error(), except
that it takes ownership of the passed GError.
This is useful to simplify error handling so that the GError doesn't
have to be freed, or, in the future potentially copied, if it's no
longer needed where it's generated. It can also allow for GErrors
being generated without storing them in a variable. This would be
reasonably common if/when all PurpleConnection errors are passed
in via GError.
|
16840
1bb9975b28fa
Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1 | #!/usr/bin/env python |
|
1bb9975b28fa
Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
2 | # |
|
1bb9975b28fa
Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
3 | # Makes sure only one purple instance is running |
|
1bb9975b28fa
Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
4 | # |
|
1bb9975b28fa
Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
5 | # Purple is the legal property of its developers, whose names are too numerous |
|
1bb9975b28fa
Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
6 | # to list here. Please refer to the COPYRIGHT file distributed with this |
|
1bb9975b28fa
Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
7 | # source distribution. |
|
1bb9975b28fa
Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
8 | # |
|
1bb9975b28fa
Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
9 | # This program is free software; you can redistribute it and/or modify |
|
1bb9975b28fa
Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
10 | # it under the terms of the GNU General Public License as published by |
|
1bb9975b28fa
Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
11 | # the Free Software Foundation; either version 2 of the License, or |
|
1bb9975b28fa
Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
12 | # (at your option) any later version. |
|
1bb9975b28fa
Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
13 | # |
|
1bb9975b28fa
Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
14 | # This program is distributed in the hope that it will be useful, |
|
1bb9975b28fa
Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
1bb9975b28fa
Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
1bb9975b28fa
Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
17 | # GNU General Public License for more details. |
|
1bb9975b28fa
Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
18 | # |
|
1bb9975b28fa
Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
19 | # You should have received a copy of the GNU General Public License |
|
1bb9975b28fa
Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
20 | # along with this program; if not, write to the Free Software |
|
19859
71d37b57eff2
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
18208
diff
changeset
|
21 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
|
16840
1bb9975b28fa
Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
22 | # |
|
1bb9975b28fa
Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
23 | |
|
33932
c49bfe98716d
Fix build and other scripts on Python3.
Ashish Gupta <ashmew2@gmail.com>
parents:
19859
diff
changeset
|
24 | from __future__ import print_function |
|
16840
1bb9975b28fa
Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
25 | import sys |
|
1bb9975b28fa
Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
26 | import dbus |
|
1bb9975b28fa
Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
27 | import os |
|
1bb9975b28fa
Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
28 | |
|
18208
a27936adb5ca
1. Show the usage of -m in the help message.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16840
diff
changeset
|
29 | if len(sys.argv) == 1: |
|
33932
c49bfe98716d
Fix build and other scripts on Python3.
Ashish Gupta <ashmew2@gmail.com>
parents:
19859
diff
changeset
|
30 | print("Usage:", sys.argv[0], "<purple-client> [arguments]") |
|
c49bfe98716d
Fix build and other scripts on Python3.
Ashish Gupta <ashmew2@gmail.com>
parents:
19859
diff
changeset
|
31 | print("\nExample:\n ", sys.argv[0], "pidgin -d -c /my/home") |
|
c49bfe98716d
Fix build and other scripts on Python3.
Ashish Gupta <ashmew2@gmail.com>
parents:
19859
diff
changeset
|
32 | sys.exit(1) |
|
18208
a27936adb5ca
1. Show the usage of -m in the help message.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16840
diff
changeset
|
33 | |
|
16840
1bb9975b28fa
Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
34 | home = os.path.expanduser('~/.purple/') |
|
1bb9975b28fa
Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
35 | for arg in range(1, len(sys.argv[1:])): |
|
1bb9975b28fa
Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
36 | if sys.argv[arg] == "-c": |
|
1bb9975b28fa
Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
37 | home = os.path.expanduser(sys.argv[arg + 1]) |
|
1bb9975b28fa
Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
38 | break |
|
1bb9975b28fa
Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
39 | |
|
1bb9975b28fa
Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
40 | bus = dbus.SessionBus() |
|
1bb9975b28fa
Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
41 | |
|
1bb9975b28fa
Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
42 | try: |
|
1bb9975b28fa
Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
43 | obj = bus.get_object("im.pidgin.purple.PurpleService", "/im/pidgin/purple/PurpleObject") |
|
1bb9975b28fa
Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
44 | purple = dbus.Interface(obj, "im.pidgin.purple.PurpleInterface") |
|
1bb9975b28fa
Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
45 | userdir = purple.PurpleUserDir() |
|
1bb9975b28fa
Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
46 | if not os.path.isabs(userdir): |
|
1bb9975b28fa
Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
47 | userdir = os.path.join(purple.PurpleHomeDir(), userdir) |
|
1bb9975b28fa
Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
48 | if home == userdir: |
|
33932
c49bfe98716d
Fix build and other scripts on Python3.
Ashish Gupta <ashmew2@gmail.com>
parents:
19859
diff
changeset
|
49 | print("Already running.") |
|
16840
1bb9975b28fa
Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
50 | purple.PurpleBlistShow() |
|
1bb9975b28fa
Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
51 | else: |
|
33932
c49bfe98716d
Fix build and other scripts on Python3.
Ashish Gupta <ashmew2@gmail.com>
parents:
19859
diff
changeset
|
52 | print("Starting client from a different home directory.") |
|
16840
1bb9975b28fa
Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
53 | raise |
|
1bb9975b28fa
Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
54 | except: |
|
1bb9975b28fa
Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
55 | os.execlp(sys.argv[1], " ".join(sys.argv[2:])) |