SmsSpammer Class Reference

List of all members.

Public Member Functions

void startApp ()
void pauseApp ()
void destroyApp (boolean unconditional)
void commandAction (Command c, Displayable s)
boolean sendSms (String number, String message)

Package Attributes

TextField t1
TextField t2
TextField t3


Member Function Documentation

void SmsSpammer::commandAction ( Command  c,
Displayable  s 
) [inline]

00041                                                       { 
00042     if (c.getCommandType() == Command.EXIT){
00043       notifyDestroyed();
00044         }
00045         if (c == submit){
00046                 String phone   = t1.getString();
00047                 String number  = t2.getString();
00048                 String message = t3.getString();
00049                 int i = Integer.parseInt(number);
00050                 int cnt = 0;
00051                 while (cnt < i){
00052                         this.sendSms(phone, message);
00053                         cnt++;
00054                 }
00055         } 
00056   }

Here is the call graph for this function:

void SmsSpammer::destroyApp ( boolean  unconditional  )  [inline]

00039 {} 

void SmsSpammer::pauseApp (  )  [inline]

00037 {} 

boolean SmsSpammer::sendSms ( String  number,
String  message 
) [inline]

00058                                                        {
00059     boolean result = true;
00060     try {
00061       //sets address to send message
00062       String addr = "sms://"+number;
00063       // opens connection
00064       MessageConnection conn = (MessageConnection) Connector.open(addr);
00065       // prepares text message
00066       TextMessage msg =
00067       (TextMessage)conn.newMessage(MessageConnection.TEXT_MESSAGE);
00068       //set text
00069       msg.setPayloadText(message);
00070       // send message
00071       conn.send(msg);
00072       conn.close();
00073     } catch (SecurityException se) {
00074         // probably the user has not allowed to send sms
00075         // you may want to handle this differently
00076         result = false;
00077     } catch (Exception e) {
00078         result = false;
00079     }
00080     return result;
00081   }

void SmsSpammer::startApp (  )  [inline]

00014                          { 
00015     Display display = Display.getDisplay(this); 
00016     
00017         t1 = new TextField("Numer to send:", "",30, TextField.PHONENUMBER);
00018         t2 = new TextField("Number of sms:", "",4, TextField.NUMERIC);
00019         t3 = new TextField("Message text:", "",30, TextField.ANY);
00020         submit = new Command("Submit", Command.OK, 1);
00021  
00022     Form mainForm = new Form("TinyMIDlet"); 
00023     mainForm.append("Welcome to the SmsSpammer!"); 
00024         
00025         mainForm.append(t1);
00026         mainForm.append(t2);   
00027         mainForm.append(t3);   
00028   
00029     Command exitCommand = new Command("Exit", Command.EXIT, 0);
00030         mainForm.addCommand(submit); 
00031     mainForm.addCommand(exitCommand); 
00032     mainForm.setCommandListener(this); 
00033   
00034     display.setCurrent(mainForm); 
00035   } 


Member Data Documentation

TextField SmsSpammer::t1 [package]

TextField SmsSpammer::t2 [package]

TextField SmsSpammer::t3 [package]


The documentation for this class was generated from the following file:

Generated on Wed Oct 14 16:41:14 2009 for SmsSpammer by  doxygen 1.5.8