Replacing None type by null list
[python-purple] / nullclient.py
1 #
2 #  Copyright (c) 2008 INdT - Instituto Nokia de Tecnologia
3 #
4 #  This file is part of python-purple.
5 #
6 #  python-purple is free software: you can redistribute it and/or modify
7 #  it under the terms of the GNU General Public License as published by
8 #  the Free Software Foundation, either version 3 of the License, or
9 #  (at your option) any later version.
10 #
11 #  python-purple is distributed in the hope that it will be useful,
12 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 #  GNU General Public License for more details.
15 #
16 #  You should have received a copy of the GNU General Public License
17 #  along with this program.  If not, see <http://www.gnu.org/licenses/>.
18 #
19
20 import ecore
21 import getpass
22 import purple
23 import sys
24
25 # The information below is needed by libpurple
26 __NAME__ = "nullclient"
27 __VERSION__ = "0.1"
28 __WEBSITE__ = "N/A"
29 __DEV_WEBSITE__ = "N/A"
30
31 if __name__ == '__main__':
32     # Sets initial parameters
33     core = purple.Purple(__NAME__, __VERSION__, __WEBSITE__, __DEV_WEBSITE__, \
34             debug_enabled=True, default_path="/tmp")
35
36     # Initializes libpurple
37     core.purple_init()
38
39     # Get username from user
40     sys.stdout.write("Enter GTalk account: ")
41     username = sys.stdin.readline()[:-1]
42
43     # Initialize protocol class
44     protocol = purple.Protocol('prpl-jabber')
45
46     # Creates new account inside libpurple
47     account = purple.Account(username, protocol, core)
48     account.new()
49
50     # Get password from user
51     account.set_password(getpass.getpass())
52
53     # Set account protocol options
54     info = {}
55     info['connect_server'] = 'talk.google.com'
56     info['port'] = '443'
57     info['old_ssl'] = True
58     account.set_protocol_options(info)
59
60     # Enable account (connects automatically)
61     account.set_enabled(True)
62
63     # Initializes ecore mainloop
64     ecore.main_loop_begin()