Updated internal class attributes with correct naming.
authorRagner Magalhaes <ragner.magalhaes@openbossa.org>
Tue, 2 Dec 2008 20:49:02 +0000 (20:49 +0000)
committerAnderson Briglia <anderson.briglia@openbossa.org>
Sat, 28 Feb 2009 21:11:13 +0000 (17:11 -0400)
FIXES:
 - Now internal class attributes are all private, which can be caught externally using property.

Signed-off-by: Bruno Abinader <bruno.abinader@indt.org.br>

git-svn-id: https://garage.maemo.org/svn/carman/branches/carman-0.7-beta2/python-purple@1355 596f6dd7-e928-0410-a184-9e12fd12cf7e

buddy.pyx
conversation.pyx

index a465b6f..5de38f7 100644 (file)
--- a/buddy.pyx
+++ b/buddy.pyx
@@ -22,7 +22,7 @@ cimport purple
 cdef class Buddy:
     """ Buddy class """
     cdef blist.PurpleBuddy *c_buddy
 cdef class Buddy:
     """ Buddy class """
     cdef blist.PurpleBuddy *c_buddy
-    cdef Account _acc
+    cdef Account __acc
 
     def __init__(self):
         self.c_buddy = NULL
 
     def __init__(self):
         self.c_buddy = NULL
@@ -30,7 +30,7 @@ cdef class Buddy:
     def __get_account(self):
         return self.__acc
     def __set_account(self, acc):
     def __get_account(self):
         return self.__acc
     def __set_account(self, acc):
-        self._acc = acc
+        self.__acc = acc
     account = property(__get_account, __set_account)
 
     def __get_alias(self):
     account = property(__get_account, __set_account)
 
     def __get_alias(self):
@@ -49,7 +49,7 @@ cdef class Buddy:
 
     def __get_online(self): # FIXME
         name = self.name
 
     def __get_online(self): # FIXME
         name = self.name
-        self.c_buddy = blist.c_purple_find_buddy(self._acc.c_account, name)
+        self.c_buddy = blist.c_purple_find_buddy(self.__acc.c_account, name)
         return status.c_purple_presence_is_online(blist.c_purple_buddy_get_presence(self.c_buddy))
     online = property(__get_online)
 
         return status.c_purple_presence_is_online(blist.c_purple_buddy_get_presence(self.c_buddy))
     online = property(__get_online)
 
index 6b44c63..588f29a 100644 (file)
@@ -24,35 +24,48 @@ cdef class Conversation:
     cdef conversation.PurpleConversation *__conv
     cdef Account __acc
 
     cdef conversation.PurpleConversation *__conv
     cdef Account __acc
 
-    cdef object name
+    cdef object __name
 
     def __init__(self):
         conversation.c_purple_conversations_init()
 
     def __init__(self):
         conversation.c_purple_conversations_init()
-        self.name = None
+        self.__name = None
+
+    def __get_account(self):
+        return self.__acc
+    def __set_account(self, acc):
+        self.__acc = acc
+    account = property(__get_account, __set_account)
+
+    def __get_name(self):
+        return self.__name
+    def __set_name(self, name):
+        self.__name = name
+    name = property(__get_name, __set_name)
 
     def initialize(self, acc, type, char *name):
         self.__acc = acc
 
     def initialize(self, acc, type, char *name):
         self.__acc = acc
+        self.__name = name
+
         if type == "UNKNOWN":
             self.__conv =\
             conversation.c_purple_conversation_new(conversation.PURPLE_CONV_TYPE_UNKNOWN,\
         if type == "UNKNOWN":
             self.__conv =\
             conversation.c_purple_conversation_new(conversation.PURPLE_CONV_TYPE_UNKNOWN,\
-                <account.PurpleAccount*>self.__acc.c_account, name)
+                <account.PurpleAccount*>self.__acc.c_account, self.__name)
         elif type == "IM":
             self.__conv =\
             conversation.c_purple_conversation_new(conversation.PURPLE_CONV_TYPE_IM,\
         elif type == "IM":
             self.__conv =\
             conversation.c_purple_conversation_new(conversation.PURPLE_CONV_TYPE_IM,\
-                <account.PurpleAccount*>self.__acc.c_account, name)
+                <account.PurpleAccount*>self.__acc.c_account, self.__name)
         elif type == "CHAT":
             self.__conv =\
             conversation.c_purple_conversation_new(conversation.PURPLE_CONV_TYPE_CHAT,\
         elif type == "CHAT":
             self.__conv =\
             conversation.c_purple_conversation_new(conversation.PURPLE_CONV_TYPE_CHAT,\
-                <account.PurpleAccount*>self.__acc.c_account, name)
+                <account.PurpleAccount*>self.__acc.c_account, self.__name)
         elif type == "MISC":
             self.__conv =\
             conversation.c_purple_conversation_new(conversation.PURPLE_CONV_TYPE_MISC,\
         elif type == "MISC":
             self.__conv =\
             conversation.c_purple_conversation_new(conversation.PURPLE_CONV_TYPE_MISC,\
-                <account.PurpleAccount*>self.__acc.c_account, name)
+                <account.PurpleAccount*>self.__acc.c_account, self.__name)
         elif type == "ANY":
             self.__conv =\
             conversation.c_purple_conversation_new(conversation.PURPLE_CONV_TYPE_ANY,\
         elif type == "ANY":
             self.__conv =\
             conversation.c_purple_conversation_new(conversation.PURPLE_CONV_TYPE_ANY,\
-                <account.PurpleAccount*>self.__acc.c_account, name)
-        self.name = name
+                <account.PurpleAccount*>self.__acc.c_account, self.__name)
 
     def conversation_set_ui_ops(self):
         cdef conversation.PurpleConversationUiOps c_conv_ui_ops
 
     def conversation_set_ui_ops(self):
         cdef conversation.PurpleConversationUiOps c_conv_ui_ops
@@ -81,5 +94,5 @@ cdef class Conversation:
         conversation.c_purple_conversations_get_handle()
 
     def destroy(self):
         conversation.c_purple_conversations_get_handle()
 
     def destroy(self):
-        print "[DEBUG]: Destroy conversation: %s" % self.name
+        print "[DEBUG]: Destroy conversation: %s" % self.__name
         conversation.c_purple_conversation_destroy(self.__conv)
         conversation.c_purple_conversation_destroy(self.__conv)