Skip to content

Commit

Permalink
Merge branch 'master' of git@github.com:drf/amsn2
Browse files Browse the repository at this point in the history
  • Loading branch information
Boris Faure committed Apr 19, 2009
2 parents 834041f + ec54cab commit daf442b
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 120 deletions.
7 changes: 5 additions & 2 deletions README
Expand Up @@ -5,6 +5,9 @@ python-pyopenssl
python-crypto
maybe some other stuff...

Before launching amsn2 you have to fetch the submodules (pymsn). Instructions can be found on the aMSN forum:
http://www.amsn-project.net/forums/viewtopic.php?t=5994

If you launch ./amsn2.py and it gives an error, that error probably tells you which dependency you need...
You can type ./amsn2.py --help for more info... and the front ends can be selected with -f :
./amsn2.py -f efl
Expand All @@ -17,9 +20,9 @@ If you want to install the EFL, it's easy go to http://omicron.homeip.net/projec
http://omicron.homeip.net/projects/easy_e17/easy_e17.sh
Then do ./easy_e17.sh -i
It will download the CVS, automake, configure, make and make install everything into /opt/e17 (so it doesn't 'contaminate' your system).
Once done, go to ./e17_cvs/proto/python-efl and type ./buildall.sh /usr (this will build and install the python extensions into /usr/python2.X/...)
Then in amsn2 directory, go to python-etk and build that too and install it...
Once done, go to ./e17_src/BINDINGS/python and type ./buildall.sh /usr (this will build and install the python extensions into /usr/python2.X/...). See README.txt in that directory for requirements.
Then the efl front end should become available...
If it's not, fire up a python shell and try to import the ecore module; diagnose from there the problem.


If you have the following error with the qt4 front-end:
Expand Down
160 changes: 42 additions & 118 deletions amsn2/gui/front_ends/curses/contact_list.py
@@ -1,54 +1,15 @@
from amsn2.gui import base
import pymsn
import curses

class Contact(object):
def __init__(self, name, presence):
self.name = name
self.presence = presence
self.p2s = {pymsn.Presence.ONLINE:"online",
pymsn.Presence.BUSY:"busy",
pymsn.Presence.IDLE:"idle",
pymsn.Presence.AWAY:"away",
pymsn.Presence.BE_RIGHT_BACK:"brb",
pymsn.Presence.ON_THE_PHONE:"phone",
pymsn.Presence.OUT_TO_LUNCH:"lunch",
pymsn.Presence.INVISIBLE:"hidden",
pymsn.Presence.OFFLINE:"offline"}


def is_online(self):
return self.presence != pymsn.Presence.OFFLINE

def status(self):
return self.p2s[self.presence]

class Group(object):
def __init__(self, name):
self.contacts = {}
self.name = name

def count(self):
online = 0
total = 0
for c in self.contacts:
total += 1
if self.contacts[c].is_online():
online +=1

return (online, total)


class aMSNContactListWindow(base.aMSNContactListWindow):
def __init__(self, amsn_core, parent):
self._amsn_core = amsn_core
self.groups = {}
self.contacts = {}
self._stdscr = parent._stdscr
(y,x) = self._stdscr.getmaxyx()
# TODO: Use a pad instead
self._win = curses.newwin(y, int(0.2*x), 0, 0)
self._win.bkgd(curses.color_pair(1))
self._win = curses.newwin(y, int(0.25*x), 0, 0)
self._win.bkgd(curses.color_pair(0))
self._win.border()
self._clwidget = aMSNContactListWidget(amsn_core, self)

def show(self):
Expand All @@ -58,109 +19,72 @@ def hide(self):
self._stdscr.clear()
self._stdscr.refresh()

def contactStateChange(self, contact):
for group in contact.groups:
self.groups[group.id].contacts[contact.id].presence = contact.presence

self.__update_view()

def contactNickChange(self, contact):
pass

def contactPSMChange(self, contact):
pass

def contactAlarmChange(self, contact):
pass

def contactDisplayPictureChange(self, contact):
pass

def contactSpaceChange(self, contact):
pass

def contactSpaceFetched(self, contact):
pass

def contactBlocked(self, contact):
pass

def contactUnblocked(self, contact):
pass

def contactMoved(self, from_group, to_group, contact):
pass

def contactAdded(self, group, contact):
self.groups[group.id].contacts[contact.id] = Contact(contact.display_name, contact.presence)
self.__update_view()

def contactRemoved(self, group, contact):
pass

def contactRenamed(self, contact):
pass

def groupRenamed(self, group):
pass

def groupAdded(self, group):
self.groups[group.id] = Group(group.name)
self.__update_view()

def groupRemoved(self, group):
pass

def configure(self, option, value):
pass

def cget(self, option, value):
pass


def __update_view(self):
self._win.clear()
row = 0
for g in self.groups:
count = self.groups[g].count()
self._win.addstr(row, 0, "%s (%d/%d)" % (self.groups[g].name, count[0], count[1]), curses.A_BOLD | curses.A_UNDERLINE)
row += 1
for c in self.groups[g].contacts:
self._win.addstr(row, 2, "%s (%s)" % (self.groups[g].contacts[c].name, self.groups[g].contacts[c].status()), curses.A_BOLD)
row += 1
row += 1

self._win.refresh()


class aMSNContactListWidget(base.aMSNContactListWidget):

def __init__(self, amsn_core, parent):
super(aMSNContactListWidget, self).__init__(amsn_core, parent)
self._groups = {}
self._contacts = {}
self._win = parent._win
self._stdscr = parent._stdscr

def contactListUpdated(self, clView):
# TODO: Implement it to sort groups and handle add/delete
# TODO: Implement it to sort groups
for g in self._groups:
if g not in clView.group_ids:
self._groups.delete(g)
for g in clView.group_ids:
self._groups[g] = None
if not self._groups.has_key(g):
self._groups[g] = None

def groupUpdated(self, gView):
if not self._groups.has_key(gView.uid):
return

if self._groups[gView.uid] is not None:
#Delete contacts
for c in self._groups[gView.uid].contact_ids:
if c not in gView.contact_ids:
if self._contacts[c]['refs'] == 1:
self._contacts.delete(c)
else:
self._contacts[c]['refs'] -= 1
#Add contacts
for c in gView.contact_ids:
if not self._contacts.has_key(c):
self._contacts[c] = {'cView': None, 'refs': 1}
continue
#If contact wasn't already there, increment reference count
if self._groups[gView.uid] is None or c not in self._groups[gView.uid].contact_ids:
self._contacts[c]['refs'] += 1
self._groups[gView.uid] = gView
self.__updateGroups()
# TODO: Implement something useful
import sys
print >> sys.stderr, gView.name

def contactUpdated(self, cView):
pass
if not self._contacts.has_key(cView.uid):
return
self._contacts[cView.uid]['cView'] = cView
self.__updateGroups()

def __updateGroups(self):
self._win.clear()
self._win.move(0,0)
for g in self._groups:
if self._groups[g] is not None:
self._win.insstr(str(self._groups[g].name))
self._win.insstr(self._groups[g].name.toString())
self._win.insch(curses.ACS_LLCORNER)
self._win.insertln()
for c in self._groups[g].contact_ids:
if self._contacts.has_key(c) and self._contacts[c]['cView'] is not None:
self._win.insstr(self._contacts[c]['cView'].name.toString())
self._win.insch(curses.ACS_HLINE)
self._win.insch(curses.ACS_HLINE)
self._win.insch(curses.ACS_LLCORNER)
self._win.insertln()
self._win.refresh()
1 change: 1 addition & 0 deletions amsn2/gui/front_ends/curses/main.py
Expand Up @@ -34,4 +34,5 @@ def setMenu(self,menu):
def __init_colors(self):
curses.start_color()
curses.init_pair(1, curses.COLOR_YELLOW, curses.COLOR_WHITE)
curses.init_pair(2, curses.COLOR_BLACK, curses.COLOR_BLUE)

0 comments on commit daf442b

Please sign in to comment.