2 # Copyright (c) 2008 INdT - Instituto Nokia de Tecnologia
4 # This file is part of python-purple.
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.
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.
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/>.
20 cdef extern from "glib.h":
23 cdef extern from "libpurple/account.h":
24 cdef struct _PurpleAccount
25 ctypedef _PurpleAccount PurpleAccount
27 PurpleAccount *c_purple_account_new "purple_account_new" (const_char_ptr username, const_char_ptr protocol_id)
28 void c_purple_account_set_password "purple_account_set_password" (PurpleAccount *account, const_char_ptr password)
29 const_char_ptr c_purple_account_get_password "purple_account_get_password" (PurpleAccount *account)
30 void c_purple_account_set_enabled "purple_account_set_enabled" (PurpleAccount *account, const_char_ptr ui, gboolean value)
31 const_char_ptr c_purple_account_get_username "purple_account_get_username" (PurpleAccount *account)
33 cdef extern from "libpurple/status.h":
34 ctypedef int PurpleStatusPrimitive
36 cdef struct _PurpleSavedStatus
37 ctypedef _PurpleSavedStatus PurpleSavedStatus
39 PurpleSavedStatus *c_purple_savedstatus_new "purple_savedstatus_new" (const_char_ptr title, PurpleStatusPrimitive type)
40 void c_purple_savedstatus_activate "purple_savedstatus_activate" (PurpleSavedStatus *saved_status)
42 cdef extern from "libpurple/proxy.h":
43 cdef struct PurpleProxyInfo
45 ctypedef int PurpleProxyType
46 PurpleProxyInfo *purple_proxy_info_new()
47 void c_purple_proxy_info_set_type "purple_proxy_info_set_type" (PurpleProxyInfo *info, PurpleProxyType type)
48 void c_purple_proxy_info_set_host "purple_proxy_info_set_host" (const_char_ptr host)
49 void c_purple_proxy_info_set_port "purple_proxy_info_set_port" (const_char_ptr port)
54 self.PROXY_USE_GLOBAL = -1
59 self.PROXY_USE_ENVVAR = 4
62 class StatusPrimitive:
65 self.STATUS_OFFLINE = 1
66 self.STATUS_AVAILABLE = 2
67 self.STATUS_UNAVAILABLE = 3
68 self.STATUS_INVISIBLE = 4
70 self.STATUS_EXTENDED_AWAY = 6
71 self.STATUS_MOBILE = 7
73 self.STATUS_NUN_PRIMITIVE = 9
77 cdef PurpleAccount *__account
78 cdef PurpleSavedStatus *__sstatus
80 def __cinit__(self, const_char_ptr username, const_char_ptr protocol_id):
81 self.__account = c_purple_account_new(username, protocol_id)
83 def set_password(self, password):
84 c_purple_account_set_password(self.__account, password)
86 def set_enabled(self, ui, value):
87 c_purple_account_set_enabled(self.__account, ui, value)
89 def get_acc_username(self):
91 return c_purple_account_get_username(self.__account)
93 def get_password(self):
95 return c_purple_account_get_password(self.__account)
98 self.__sstatus = c_purple_savedstatus_new(NULL, StatusPrimitive().STATUS_AVAILABLE)
99 c_purple_savedstatus_activate(self.__sstatus)