this is my first attempt to implement OOP. IS this class ok?(in terms of structure)
AND another Question:
there are some folders in message application in Symbian phones
and sometimes there are up to 1000 messages in each folders.
I do itterate over all messages for gathering their info about sender/reciever/etc
but its very slow to use this clas for every folder.
how can I make a class that prevents me from itteratin over and over?
some info:
a messaging folder accessed from python returns a list of IDs from all of messages
for every ID there is a dict that contains info about that message.

#-------------------------------------------------------------------------------
# Name:        DelSMS
# Purpose:     Application for deleting SMS messages in Nokia Symbian Phones
# Author:      M.S.
# Created:     22/09/2012
# Copyright:   (c) Mohsen Sarhady 2012
# Python Version:     PyS60 v1.45(Python 2.2.2)
#-------------------------------------------------------------------------------
# -*- coding: utf-8 -*-

import inbox

class DelSMS:
    """Class for deleting SMS messages with diferent possibilities:
       -Dlete Messages in different folders
       -Delete Messages for a contact in different folders
       -Delete messages that contain a search keyword"""

    def __init__(self, folder):
        self.folder=folder
        self.m=folder.sms_messages()

    def contacts_by_folder(self):
        """Returns the list of contacts in the given folder."""
        contacts = []
        if len(self.m) != 0:
            for idx in self.m:
                address = self.folder.address(idx)
                if address not in contacts:
                    contacts.append(address)
        contacts.sort()
        return contacts

    def del_by_folder(self):
        """Deletes messages in the given folder."""
        if len(self.m) != 0:
            for idx in self.m:
                self.folder.delete(idx)

    def del_by_contact(self, contact):
        """Deletes Messages by Contact in the given folder."""
        if len(self.m) != 0:
            for idx in self.m:
                address = self.folder.address(idx)
                if address == contact:
                    folder.delete(idx)

    def del_by_keyword(self, keyword):
        """Deletes messages that contain a given search term"""
        #It is a TO DO
        pass


if __name__ == '__main__':
    #Test:
    delsms = DelSMS(inbox.Inbox(inbox.ESent))
    contacts = delsms.contacts()
    print contacts

Recommended Answers

All 2 Replies

I would think you would be better off to add functionality to inbox.Inbox by inheriting, I do not see what object the DelSMS corresponds with.

actually inbox.Inbox in my phone(s60v3 n95) lacks some functionallity that I need.say for example, if I wanted to delete only recived messages from only one contact among 60 contacts and 1300+ SMSs, there is no option to do that.
(in newer symbian^3 it is almost possible, but not in s60v3).

I am just using the Python API for accessing Messaging on my phone. this class is just for collecting the functions I want use for each messaging folder(i.e. Inbox, Sent, Draft, Outbox).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.