From af63bece9d35071de457b059b60c97e9795fcb88 Mon Sep 17 00:00:00 2001 From: Ragner Magalhaes Date: Tue, 2 Dec 2008 20:16:59 +0000 Subject: [PATCH] More fixes to BFP. FIXES: - Created savedstatuses.pxd. Signed-off-by: Bruno Abinader git-svn-id: https://garage.maemo.org/svn/carman/branches/carman-0.7-beta2/python-purple@1289 596f6dd7-e928-0410-a184-9e12fd12cf7e --- account.pxd | 68 +++++++++++++++++++++++++++++++++++++++++++ account.pyx | 68 ------------------------------------------- buddy.pxd | 34 ++++++++++++++++++++++ buddy.pyx | 34 ---------------------- connection.pxd | 25 ++++++++++++++++ connection.pyx | 25 ---------------- conversation.pxd | 62 +++++++++++++++++++++++++++++++++++++++ conversation.pyx | 62 --------------------------------------- libpurple/savedstatuses.pxd | 25 ++++++++++++++++ libpurple/status.pxd | 5 ---- purple.pyx | 16 +++++----- 11 files changed, 223 insertions(+), 201 deletions(-) create mode 100644 account.pxd delete mode 100644 account.pyx create mode 100644 buddy.pxd delete mode 100644 buddy.pyx create mode 100644 connection.pxd delete mode 100644 connection.pyx create mode 100644 conversation.pxd delete mode 100644 conversation.pyx create mode 100644 libpurple/savedstatuses.pxd diff --git a/account.pxd b/account.pxd new file mode 100644 index 0000000..cafdf07 --- /dev/null +++ b/account.pxd @@ -0,0 +1,68 @@ +# +# Copyright (c) 2008 INdT - Instituto Nokia de Tecnologia +# +# This file is part of python-purple. +# +# python-purple 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 3 of the License, or +# (at your option) any later version. +# +# python-purple 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 this program. If not, see . +# + +class ProxyType: + def __init__(self): + self.PROXY_USE_GLOBAL = -1 + self.PROXY_NONE = 0 + self.PROXY_HTTP = 1 + self.PROXY_SOCKS4 = 2 + self.PROXY_SOCKS5 = 3 + self.PROXY_USE_ENVVAR = 4 + + +class StatusPrimitive: + def __init__(self): + self.STAUTS_UNSET = 0 + self.STATUS_OFFLINE = 1 + self.STATUS_AVAILABLE = 2 + self.STATUS_UNAVAILABLE = 3 + self.STATUS_INVISIBLE = 4 + self.STATUS_AWAY = 5 + self.STATUS_EXTENDED_AWAY = 6 + self.STATUS_MOBILE = 7 + self.STATUS_TUNE = 8 + self.STATUS_NUN_PRIMITIVE = 9 + +cdef class Account: + """ Account class """ + cdef PurpleAccount *__account + cdef PurpleSavedStatus *__sstatus + + def __cinit__(self, const_char_ptr username, const_char_ptr protocol_id): + self.__account = c_purple_account_new(username, protocol_id) + + def set_password(self, password): + c_purple_account_set_password(self.__account, password) + + def set_enabled(self, ui, value): + c_purple_account_set_enabled(self.__account, ui, value) + + def get_acc_username(self): + if self.__account: + return c_purple_account_get_username(self.__account) + + def get_password(self): + if self.__account: + return c_purple_account_get_password(self.__account) + + def set_status(self): + self.__sstatus = c_purple_savedstatus_new(NULL, StatusPrimitive().STATUS_AVAILABLE) + c_purple_savedstatus_activate(self.__sstatus) + diff --git a/account.pyx b/account.pyx deleted file mode 100644 index cafdf07..0000000 --- a/account.pyx +++ /dev/null @@ -1,68 +0,0 @@ -# -# Copyright (c) 2008 INdT - Instituto Nokia de Tecnologia -# -# This file is part of python-purple. -# -# python-purple 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 3 of the License, or -# (at your option) any later version. -# -# python-purple 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 this program. If not, see . -# - -class ProxyType: - def __init__(self): - self.PROXY_USE_GLOBAL = -1 - self.PROXY_NONE = 0 - self.PROXY_HTTP = 1 - self.PROXY_SOCKS4 = 2 - self.PROXY_SOCKS5 = 3 - self.PROXY_USE_ENVVAR = 4 - - -class StatusPrimitive: - def __init__(self): - self.STAUTS_UNSET = 0 - self.STATUS_OFFLINE = 1 - self.STATUS_AVAILABLE = 2 - self.STATUS_UNAVAILABLE = 3 - self.STATUS_INVISIBLE = 4 - self.STATUS_AWAY = 5 - self.STATUS_EXTENDED_AWAY = 6 - self.STATUS_MOBILE = 7 - self.STATUS_TUNE = 8 - self.STATUS_NUN_PRIMITIVE = 9 - -cdef class Account: - """ Account class """ - cdef PurpleAccount *__account - cdef PurpleSavedStatus *__sstatus - - def __cinit__(self, const_char_ptr username, const_char_ptr protocol_id): - self.__account = c_purple_account_new(username, protocol_id) - - def set_password(self, password): - c_purple_account_set_password(self.__account, password) - - def set_enabled(self, ui, value): - c_purple_account_set_enabled(self.__account, ui, value) - - def get_acc_username(self): - if self.__account: - return c_purple_account_get_username(self.__account) - - def get_password(self): - if self.__account: - return c_purple_account_get_password(self.__account) - - def set_status(self): - self.__sstatus = c_purple_savedstatus_new(NULL, StatusPrimitive().STATUS_AVAILABLE) - c_purple_savedstatus_activate(self.__sstatus) - diff --git a/buddy.pxd b/buddy.pxd new file mode 100644 index 0000000..fa3be79 --- /dev/null +++ b/buddy.pxd @@ -0,0 +1,34 @@ +# +# Copyright (c) 2008 INdT - Instituto Nokia de Tecnologia +# +# This file is part of python-purple. +# +# python-purple 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 3 of the License, or +# (at your option) any later version. +# +# python-purple 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 this program. If not, see . +# + +cdef class Buddy: + """ Buddy class """ + cdef PurpleBuddy *__buddy + + def __cinit__(self): + self.__buddy = NULL + + def new_buddy(self, acc, const_char_ptr scr, const_char_ptr alias): + self.__buddy = c_purple_buddy_new(acc.__account, scr, alias) + + def get_alias(self): + return c_purple_buddy_get_alias_only(self.__buddy) + + def get_name(self): + return c_purple_buddy_get_name(self.__buddy) diff --git a/buddy.pyx b/buddy.pyx deleted file mode 100644 index fa3be79..0000000 --- a/buddy.pyx +++ /dev/null @@ -1,34 +0,0 @@ -# -# Copyright (c) 2008 INdT - Instituto Nokia de Tecnologia -# -# This file is part of python-purple. -# -# python-purple 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 3 of the License, or -# (at your option) any later version. -# -# python-purple 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 this program. If not, see . -# - -cdef class Buddy: - """ Buddy class """ - cdef PurpleBuddy *__buddy - - def __cinit__(self): - self.__buddy = NULL - - def new_buddy(self, acc, const_char_ptr scr, const_char_ptr alias): - self.__buddy = c_purple_buddy_new(acc.__account, scr, alias) - - def get_alias(self): - return c_purple_buddy_get_alias_only(self.__buddy) - - def get_name(self): - return c_purple_buddy_get_name(self.__buddy) diff --git a/connection.pxd b/connection.pxd new file mode 100644 index 0000000..1531059 --- /dev/null +++ b/connection.pxd @@ -0,0 +1,25 @@ +# +# Copyright (c) 2008 INdT - Instituto Nokia de Tecnologia +# +# This file is part of python-purple. +# +# python-purple 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 3 of the License, or +# (at your option) any later version. +# +# python-purple 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 this program. If not, see . +# + +cdef class Connection: + """ Connection class """ + cdef PurpleConnection *__conn + + def connect(self): + connect_to_signals_for_demonstration_purposes_only() diff --git a/connection.pyx b/connection.pyx deleted file mode 100644 index 1531059..0000000 --- a/connection.pyx +++ /dev/null @@ -1,25 +0,0 @@ -# -# Copyright (c) 2008 INdT - Instituto Nokia de Tecnologia -# -# This file is part of python-purple. -# -# python-purple 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 3 of the License, or -# (at your option) any later version. -# -# python-purple 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 this program. If not, see . -# - -cdef class Connection: - """ Connection class """ - cdef PurpleConnection *__conn - - def connect(self): - connect_to_signals_for_demonstration_purposes_only() diff --git a/conversation.pxd b/conversation.pxd new file mode 100644 index 0000000..ecb00bc --- /dev/null +++ b/conversation.pxd @@ -0,0 +1,62 @@ +# +# Copyright (c) 2008 INdT - Instituto Nokia de Tecnologia +# +# This file is part of python-purple. +# +# python-purple 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 3 of the License, or +# (at your option) any later version. +# +# python-purple 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 this program. If not, see . +# + +cdef class Conversation: + """ Conversation class """ + cdef PurpleConversation *__conv + + def __cinit__(self): + purple_conversations_init() + + def conversation_new(self, type, acc, const_char_ptr name): + self.__conv = purple_conversation_new(type, acc.__account, name) + + def conversation_set_ui_ops(self): + cdef PurpleConversationUiOps c_conv_ui_ops + c_conv_ui_ops.create_conversation = NULL + c_conv_ui_ops.destroy_conversation = NULL + c_conv_ui_ops.write_chat = NULL + c_conv_ui_ops.write_im = NULL + c_conv_ui_ops.write_conv = NULL + c_conv_ui_ops.chat_add_users = NULL + c_conv_ui_ops.chat_rename_user = NULL + c_conv_ui_ops.chat_remove_users = NULL + c_conv_ui_ops.chat_update_user = NULL + c_conv_ui_ops.present = NULL + c_conv_ui_ops.has_focus = NULL + c_conv_ui_ops.custom_smiley_add = NULL + c_conv_ui_ops.custom_smiley_write = NULL + c_conv_ui_ops.custom_smiley_close = NULL + c_conv_ui_ops.send_confirm = NULL + + purple_conversation_set_ui_ops(self.__conv, &c_conv_ui_ops) + + def conversation_write(self, const_char_ptr message): + purple_conv_im_send(purple_conversation_get_im_data(self.__conv), message) + + def conversation_destroy(self): + purple_conversation_destroy(self.__conv) + + def conversation_get_handle(self): + purple_conversations_get_handle() + + def send_message(self, buddy, const_char_ptr message): + self.conversation_new(1, buddy.account, buddy.name) + self.conversation_set_ui_ops() + self.conversation_write(message) diff --git a/conversation.pyx b/conversation.pyx deleted file mode 100644 index ecb00bc..0000000 --- a/conversation.pyx +++ /dev/null @@ -1,62 +0,0 @@ -# -# Copyright (c) 2008 INdT - Instituto Nokia de Tecnologia -# -# This file is part of python-purple. -# -# python-purple 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 3 of the License, or -# (at your option) any later version. -# -# python-purple 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 this program. If not, see . -# - -cdef class Conversation: - """ Conversation class """ - cdef PurpleConversation *__conv - - def __cinit__(self): - purple_conversations_init() - - def conversation_new(self, type, acc, const_char_ptr name): - self.__conv = purple_conversation_new(type, acc.__account, name) - - def conversation_set_ui_ops(self): - cdef PurpleConversationUiOps c_conv_ui_ops - c_conv_ui_ops.create_conversation = NULL - c_conv_ui_ops.destroy_conversation = NULL - c_conv_ui_ops.write_chat = NULL - c_conv_ui_ops.write_im = NULL - c_conv_ui_ops.write_conv = NULL - c_conv_ui_ops.chat_add_users = NULL - c_conv_ui_ops.chat_rename_user = NULL - c_conv_ui_ops.chat_remove_users = NULL - c_conv_ui_ops.chat_update_user = NULL - c_conv_ui_ops.present = NULL - c_conv_ui_ops.has_focus = NULL - c_conv_ui_ops.custom_smiley_add = NULL - c_conv_ui_ops.custom_smiley_write = NULL - c_conv_ui_ops.custom_smiley_close = NULL - c_conv_ui_ops.send_confirm = NULL - - purple_conversation_set_ui_ops(self.__conv, &c_conv_ui_ops) - - def conversation_write(self, const_char_ptr message): - purple_conv_im_send(purple_conversation_get_im_data(self.__conv), message) - - def conversation_destroy(self): - purple_conversation_destroy(self.__conv) - - def conversation_get_handle(self): - purple_conversations_get_handle() - - def send_message(self, buddy, const_char_ptr message): - self.conversation_new(1, buddy.account, buddy.name) - self.conversation_set_ui_ops() - self.conversation_write(message) diff --git a/libpurple/savedstatuses.pxd b/libpurple/savedstatuses.pxd new file mode 100644 index 0000000..d6430e8 --- /dev/null +++ b/libpurple/savedstatuses.pxd @@ -0,0 +1,25 @@ +# +# Copyright (c) 2008 INdT - Instituto Nokia de Tecnologia +# +# This file is part of python-purple. +# +# python-purple 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 3 of the License, or +# (at your option) any later version. +# +# python-purple 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 this program. If not, see . +# + +cdef extern from "libpurple/savedstatuses.h": + ctypedef struct PurpleSavedStatus: + pass + + PurpleSavedStatus *c_purple_savedstatus_new "purple_savedstatus_new" (const_char_ptr title, PurpleStatusPrimitive type) + void c_purple_savedstatus_activate "purple_savedstatus_activate" (PurpleSavedStatus *saved_status) diff --git a/libpurple/status.pxd b/libpurple/status.pxd index 86a6554..2326906 100644 --- a/libpurple/status.pxd +++ b/libpurple/status.pxd @@ -21,9 +21,4 @@ cdef extern from "libpurple/status.h": ctypedef struct PurplePresence: pass - ctypedef struct PurpleSavedStatus: - pass - ctypedef int PurpleStatusPrimitive - PurpleSavedStatus *c_purple_savedstatus_new "purple_savedstatus_new" (const_char_ptr title, PurpleStatusPrimitive type) - void c_purple_savedstatus_activate "purple_savedstatus_activate" (PurpleSavedStatus *saved_status) diff --git a/purple.pyx b/purple.pyx index e49067e..d402e2b 100644 --- a/purple.pyx +++ b/purple.pyx @@ -40,6 +40,7 @@ include "libpurple/pounce.pxd" include "libpurple/prefs.pxd" include "libpurple/proxy.pxd" include "libpurple/status.pxd" +include "libpurple/savedstatuses.pxd" include "libpurple/util.pxd" cdef extern from "c_purple.h": @@ -158,9 +159,7 @@ cdef class Purple: c_purple_pounces_load() return ret - # core_init - -# Purple + # purple_init def get_protocols(self): cdef GList *iter @@ -173,12 +172,15 @@ cdef class Purple: protocols += [(plugin.info.id, plugin.info.name)] iter = iter.next return protocols + # get_protocols def connect(self): conn = Connection() conn.connect() + # connect +# Purple -include "account.pyx" -include "buddy.pyx" -include "connection.pyx" -include "conversation.pyx" +include "account.pxd" +include "buddy.pxd" +include "connection.pxd" +include "conversation.pxd" -- 1.7.9.5