Active Topics

 


Reply
Thread Tools
pakr's Avatar
Posts: 21 | Thanked: 13 times | Joined on Jun 2008 @ Germany
#1
This is a simple python app to send (currently free) sms with one of the Betamax VOIP services. It's cheap and simple. Because I have no time to dig deeper into python and pygtk, I hope somebody with better python voodoo skills can take over this script and improve it. You can take full credits for this script.
I also have a version which is using the build in addressbook though python2.5-evolution, but it's only able to fetch the first phone number of a contact - not really usable, PM me if you would like to have it.

I would like to see: full integration with the addressbook, but without python-abook it's probably not possible. Dropdown contacts editor. Preferences. Deb file?

Installation:
You need python for this, the quickest way to get python with all the necessary stuff is to install gPodder from the extras.

# vi /usr/local/bin/betamax.py
Code:
#!/usr/bin/python
##############################################################
#   Betamax SMS
#   By: me
#   License: GNU General Public License v2 or later
##############################################################
#   Enter recipients phone number in the field, or select 
#   a contact from the dropdown list, type your message and
#   click the send button. Sometimes the Betamax server returns
#   an error, but the SMS is delivered successfuly, this also
#   happens through web - nothing I can fix.
##############################################################
import gtk, hildon, sys, osso, time, re, gobject
import os.path
import threading
import urllib
gtk.gdk.threads_init()

class HildonSMSWorld(hildon.Program):
  listStore = gtk.ListStore(str, str)
##############################################################
#   Config me
##############################################################  
  username = "myuser"
  password = "mypass"
  
  # enter your username here OR your verified number you have preset in the Windows Client.
  mynumber = "+49213432"
  
  # see the SMS instructions on the Betamax site
  url = "https://myaccount.VoipCheap.com/clx/sendsms.php"
  #url = "https://myaccount.VoipDiscount.com/clx/sendsms.php"
  #url = "https://myaccount.12voip.com/clx/sendsms.php"
  #url = "https://myaccount.sparvoip.de/clx/sendsms.php"
  # etc...
  
  # this is your dropdown list, you can add more contacts by following this schema
  listStore.insert(0, ['Some guy', '+49234'])
  listStore.insert(1, ['Some gal', '+491345'])
  listStore.insert(2, ['Somebody else', '+493456'])
  #listStore.insert(3, ['etc', '+49xxxx'])
##############################################################
# Done  
##############################################################

  def __init__(self):
    hildon.Program.__init__(self)    
    self.window = hildon.Window()
    self.add_window(self.window)

    self.window.set_title('BetamaxSMS')
    self.window.set_icon_name('qgn_toolb_messagin_send')
    
    self.window.connect("destroy", gtk.main_quit)
 
    vb = gtk.VBox()
    vb.set_spacing( 6)
    vb.set_border_width( 12)
    self.window.add( vb)

    tb = gtk.HBox()
    tb.set_spacing(6)
    vb.pack_start(tb, False)

    tel_icon = gtk.image_new_from_icon_name( 'qgn_addr_icon_details_phone', gtk.ICON_SIZE_BUTTON)
    tb.pack_start(tel_icon, False)

    self.mycontact = gtk.ComboBoxEntry(self.listStore)
    tb.pack_start(self.mycontact, True)

    self.message = gtk.TextView()
    self.message.set_wrap_mode( gtk.WRAP_WORD)
    frame = gtk.Frame()
    frame.set_shadow_type( gtk.SHADOW_IN)
    frame.add( self.message)
    vb.pack_start( frame, True)


    self.textbuffer = self.message.get_buffer()
    self.textbuffer.connect('changed', self._updateCount)

    self._add_menu()
    self._add_toolbar()
    self.window.show_all()
    
  def _getno(self):
      if not self.mycontact.get_active() == -1:
        theno = self.listStore[self.mycontact.get_active()][1]
      else:
        p = re.compile(r'^(\+[0-9]+)$')
        if p.search(self.mycontact.child.get_text()):
          theno = p.search(self.mycontact.child.get_text()).group(1)
        else:
          theno = None
      return theno

  def _updateCount(self, widget):
    charactersInText = self.textbuffer.get_char_count()
    self.tlbItmLabel.set_label( str(160 - charactersInText) )

  def _add_menu(self):
    menu = gtk.Menu()

    mnuItmSend = gtk.MenuItem("Send")
    mnuItmSend.connect("activate", self.send_sms)
    menu.add(mnuItmSend)

    mnuSpacer = gtk.SeparatorMenuItem()
    menu.add(mnuSpacer)
    mnuItmAbout = gtk.MenuItem("About")
    mnuItmAbout.connect("activate", self._show_about)
    menu.add(mnuItmAbout)
    mnuItmQuit = gtk.MenuItem("Quit")
    mnuItmQuit.connect("activate", gtk.main_quit)
    menu.add(mnuItmQuit)
    self.set_common_menu(menu)
    
  def _add_toolbar(self):
    toolbar = gtk.Toolbar()
    toolbar.expand = True
    self.tlbItmSend = gtk.ToolButton(label='Send')
    self.tlbItmSend.set_icon_name('qgn_toolb_messagin_send')    
    self.tlbItmSend.connect("clicked", self.send_sms)
    toolbar.insert(self.tlbItmSend, -1)
    
    self.tlbItmLabel = gtk.ToolButton(label='160')    
    toolbar.insert(self.tlbItmLabel, -1)

    self.set_common_toolbar(toolbar)
    toolbar.show_all()
  def _show_about(self, event):
    dlg = gtk.AboutDialog()
    dlg.set_version("0.1")
    dlg.set_name("BetamaxSMS")
    dlg.set_authors(["pakr from itt forums"])
    def close(w, res):
      if res == gtk.RESPONSE_CANCEL:
        w.hide()
    dlg.connect("response", close)
    dlg.show()

  def send_sms( self, widget):
      self.tlbItmSend.set_sensitive( False)
      threading.Thread( target = self.send_sms_thread).start()

  def send_sms_thread( self):
      buf = self.message.get_buffer()
      message = buf.get_text( buf.get_start_iter(), buf.get_end_iter())
      number = self._getno()
      if not number:
        self.tlbItmSend.set_sensitive( True)
        self.info_message( "Not a number" )
        return
      for message in self.send_message( number, message):
        gobject.idle_add( lambda: self.info_message( message ))
      self.tlbItmSend.set_sensitive( True)
      

  def info_message(self, message):
      osso_c = osso.Context("osso_test_note", "0.0.1", False)
      note = osso.SystemNote(osso_c)
      result = note.system_note_infoprint(message)

  def send_message( self, to, msg):
    yield "Sending..."
    msg = urllib.urlencode({"username": self.username, "password": self.password, "from": self.mynumber, "to": to, "text": msg})
    request = self.url + "?%s" % msg
    data = urllib.urlopen(request).read()
    print data
        
    p = re.compile(r'<description>(.*?)<\/description>')
    if p.search(data).group(1) == "":
      yield "Success"
    else:
      yield p.search(data).group(1)

  def run(self):
    gtk.main()
if __name__ == "__main__":
  app = HildonSMSWorld()
  app.run()
# chmod +x /usr/local/bin/betamax.py

# vi /usr/share/applications/hildon/betamax.desktop
Code:
[Desktop Entry]
Name=BetamaxSMS
GenericName=BetamaxSMS
Comment=Sends SMS with Voipcheap
Exec=betamax.py
Icon=qgn_toolb_messagin_send
Terminal=false
Type=Application
Categories=Communication;Extras;GTK;
StartupWMClass=betamax.py
You should now have BetamaxSMS in your Extras menu.
Attached Images
 
Attached Files
File Type: zip betamax.zip (3.4 KB, 439 views)
 

The Following 8 Users Say Thank You to pakr For This Useful Post:
Matyas's Avatar
Posts: 87 | Thanked: 25 times | Joined on Jul 2007 @ Italy
#2
Dear Pakr

I just would like to thank your effort. It is just great. I would like to point out that this program works with voipcheap, voipbuster and co. so many of us are already subscribers (free sms for all but Italy).

Regards,
Mattia
__________________
Nouveau venu ? Je peux vous aider :

Toutes les informations utiles (pages encore en anglais) : Présentez-vous à la communauté , L'essentiel pour bien commencer, Débuter sur Maemo 4 (N800 - N810), Le Wiki sur Maemo 5 (N900), La FAQ, Le sous-forum dédié aux communautés

En cas de souci, n'hésitez pas à me poser vos questions!

----------------

Benvenuto! Se hai bisogno di aiuto, sono a disposizione.
Ecco dove iniziare (in inglese):

Presentazioni dei nuovi iscritti,Primi passi per nuovi iscritti, Wiki per chi inizia con Maemo 4 (N800 - N810), Wiki per chi inizia con Maemo 5 (N900), FAQ, Subforum della Comunità

In caso di dubbi o domande non esitare: contattami!
 
maya's Avatar
Posts: 141 | Thanked: 5 times | Joined on Dec 2009 @ Brasil
#3
Hi, very good, but...

works with the N900? send multiple SMS? has contacts book?

thanks
 
Posts: 121 | Thanked: 75 times | Joined on Oct 2009
#4
I wrote an app called webtexter for the N900 which works will all betamax providers.

It includes contact selection from address book, you can send to multiple contacts and it can save sent messages to conversations application.
 

The Following User Says Thank You to matrim For This Useful Post:
jcompagner's Avatar
Posts: 290 | Thanked: 165 times | Joined on Sep 2009
#5
yes webtexter works great. its a nice touch that it will (or can) save the messages to the contacts conversations.

One step further would be if the send button in a conversation would be over-ridable so that i can say: always ask (gsm or voip), always gsm, always voip!
 
jcompagner's Avatar
Posts: 290 | Thanked: 165 times | Joined on Sep 2009
#6
or maybe even better is that the webtexter will be something like a contacts protocol plugin
that adds a voipsms button to the contact card... just like phone, sms or google talk, i only dont know if you just can add a button to all contacts because all other protocol plugins has there own contacts that you then have to merge...
 
maya's Avatar
Posts: 141 | Thanked: 5 times | Joined on Dec 2009 @ Brasil
#7
Originally Posted by matrim View Post
I wrote an app called webtexter for the N900 which works will all betamax providers.

It includes contact selection from address book, you can send to multiple contacts and it can save sent messages to conversations application.

yes, very good!
but all these dependent files are already on the N900 or have to install one by one?

http://maemo.org/packages/package_in...btexter/0.7.4/
 
Posts: 121 | Thanked: 75 times | Joined on Oct 2009
#8
Originally Posted by maya View Post
yes, very good!
but all these dependent files are already on the N900 or have to install one by one?

http://maemo.org/packages/package_in...btexter/0.7.4/
They should be there already or if not when you install from the app manager it will install them automatically.
 
maya's Avatar
Posts: 141 | Thanked: 5 times | Joined on Dec 2009 @ Brasil
#9
Originally Posted by matrim View Post
They should be there already or if not when you install from the app manager it will install them automatically.
oh, very good.
I try to install, because here in Brazil the SMS is very expensive and this your app will be very useful. thanks!
 
maya's Avatar
Posts: 141 | Thanked: 5 times | Joined on Dec 2009 @ Brasil
#10
Originally Posted by maya View Post
oh, very good.
I try to install, because here in Brazil the SMS is very expensive and this your app will be very useful. thanks!
well, I installed webtexto and opened correctly, my voip provider is voipbusterpro
it allows you to enter the numbers in two formats. with + or 00 as instructed by the site: http://voipbusterpro.com/en/sms_instructions.html
but is reporting an undefined error. have any suggestions?
thanks!
 
Reply


 
Forum Jump


All times are GMT. The time now is 18:45.