Re: [Sugar-devel] [PATCH sugar] Don't treat SSID as UTF-8 character sequence (fixes SL#2023)

2012-04-16 Thread Simon Schampijer

On 04/02/2012 06:40 PM, Sascha Silbe wrote:

IEEE 802.11 [2] defines the SSID as a sequence of octets (i.e. bytes), but
Sugar treated it as UTF-8 character data. While in most cases the SSID is
actually some human-readable string, there's neither a guarantee for that nor
does any (de-facto or de-jure) standard specify the encoding to use. As a
result, we'll encounter SSIDs in a large variety of encodings and will also
need to cope with arbitrary byte strings. Any assumption of a single (or in
fact any) character encoding is incorrect.

The D-Bus API of NetworkManager 0.9 [3] passes SSIDs as uninterpreted byte
strings (D-Bus signature ay). Before SSIDs can be displayed on screen, some
kind of interpretation must happen.

NetworkManager has a rather elaborate heuristic that takes the user locale into
account. In the future (i.e. when the NetworkManager client code in Sugar has
been ported to gobject-introspection) we may use nm_utils_ssid_to_utf8() [4],
but for now we're doing the following to allow the user to use non-UTF-8 APs at
all:

1. If the SSID is a valid character string consisting only of
printable characters in one of the following encodings (tried in
the given order), decode it accordingly:
UTF-8, ISO-8859-1, Windows-1251.

2. Return a hex dump of the SSID.

The first rule should cover the majority of current Sugar users and hopefully
all AP vendors will switch to UTF-8 eventually. In the meantime, the second
rule allows users to distinguish between several APs with SSIDs in unknown
encodings (or even using arbitrary byte sequences that don't _have_ a character
representation).

Tested:
- filtering on ASCII and non-ASCII parts of the name of and connecting to:
   - an unsecured AP with a UTF-8 SSID (äöü߀sugartest, HostAP)
   - an unsecured AP with an ISO-8859-1 SSID (äöüßsugartest, HostAP)
   - an unsecured AP with a non-character SSID (0d:06:f0:0d, HostAP)
   - a WEP-secured AP with a UTF-8 name (äöü߀sugartest2, HostAP)
   - a WEP-secured AP with an ISO-8859-1 name (äöüßsugartest2, HostAP)
   - a WEP-secured AP with a non-character SSID (0d:06:f0:0d, HostAP)
   - a WPA-secured AP with an ASCII name (COTS AP)

In each case the name was displayed correctly in
a) the palette of the AP icon in the Neighbourhood,
b) the palette of the wireless network Frame device and
c) the title of the WLAN credentials (WEP/WPA passphrase) dialog (for
the WEP/WPA cases).

[1] https://bugs.sugarlabs.org/ticket/2023
[2] http://standards.ieee.org/getieee802/download/802.11-2007.pdf
[3] http://projects.gnome.org/NetworkManager/developers/api/09/spec.html
[4] 
http://projects.gnome.org/NetworkManager/developers/libnm-util/09/libnm-util-nm-utils.html#nm-utils-ssid-to-utf8

Signed-off-by: Sascha Silbesi...@activitycentral.com


Thanks for the patch, looks good. I tested here with my AP that does 
announce in non utf-8 char and it works fine.


I still don't see the hex-dump as needed but ok, if you have tested it, 
I am happy with it.


I opened #3451 to track the porting to use nm_utils_ssid_to_utf8 from 
libnm.


Regards,
   Simon
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


[Sugar-devel] [PATCH sugar] Fix shortcut for view source

2012-04-16 Thread Simon Schampijer
This is a follow up of 26df35b0c02881864d0f47782f8ff5b5ce5e187c,
OLPC #11721. You can now use again 'fn+space' to reveal the
source view of an activity. The keyname was determined using
xev.

Signed-off-by: Simon Schampijer si...@laptop.org
---
 extensions/globalkey/viewsource.py |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/extensions/globalkey/viewsource.py 
b/extensions/globalkey/viewsource.py
index 96e7c6b..e0f5ef8 100644
--- a/extensions/globalkey/viewsource.py
+++ b/extensions/globalkey/viewsource.py
@@ -19,7 +19,7 @@ from jarabe.view.viewsource import setup_view_source
 from jarabe.model import shell
 
 
-BOUND_KEYS = ['0xEC', 'altshiftv']
+BOUND_KEYS = ['XF86KbdLightOnOff', 'altshiftv']
 
 
 def handle_key_press(key):
-- 
1.7.7.6

___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


Re: [Sugar-devel] [PATCH] keyhandler: Use textual key names

2012-04-16 Thread Simon Schampijer

On 03/28/2012 11:40 PM, Peter Robinson wrote:

On Tue, Mar 27, 2012 at 9:22 PM, Daniel Draked...@laptop.org  wrote:

Conversion of 0x## keycodes is broken in libegg with recent GDK.

Switch to the textual names of the keys in question to work around this
bug, reference:  https://bugzilla.gnome.org/show_bug.cgi?id=672950

This fixes the frame key on XO laptops running Fedora 17.

Signed-off-by: Daniel Draked...@laptop.org
---
  src/jarabe/view/keyhandler.py |4 ++--
  1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/jarabe/view/keyhandler.py b/src/jarabe/view/keyhandler.py
index a71f260..530da75 100644
--- a/src/jarabe/view/keyhandler.py
+++ b/src/jarabe/view/keyhandler.py
@@ -51,11 +51,11 @@ _actions_table = {
 'XF86AudioRaiseVolume': 'volume_up',
 'altF11': 'volume_min',
 'altF12': 'volume_max',
-'0x93': 'frame',
+'XF86MenuKB': 'frame',
 'altTab': 'next_window',
 'altshiftTab': 'previous_window',
 'altEscape': 'close_window',
-'0xDC': 'open_search',
+'XF86WebCam': 'open_search',
  # the following are intended for emulator users
 'altshiftf': 'frame',
 'altshiftq': 'quit_emulator',


I think we need a similar fix for the Fn key, I gett repeating = signs
on a 1.75-HS and it doesn't work for pg-up dg-down on the XO-1/XO1.5
membrane keyboard.

Peter


In os7 I can use fn+pg-up/pg-down fine (tested with membrane keyboard 
with a XO-1.5). But there was one shortcut missing indeed in the 
conversion, the one for the view source: 
http://lists.sugarlabs.org/archive/sugar-devel/2012-April/036655.html


Thanks for productively noising,
   Simon
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


[Sugar-devel] [PATCH sugar] Create a default unencrypted keyring, OLPC #10290

2012-04-16 Thread Simon Schampijer
This patch does create an ununcrypted default keyring
if there is not one available already. This will stop
prompts for unlocking the keyring after logging into
Sugar.

In GNOME the session manager deals with creating
that keyring. In the OLPC images we do create a default
keyring on image creation time (see olpc-configure), same
is true for Soas. This patch does check/create the
keyring on every Sugar run. The advantage is that
for example installs the live image to a disk install
using liveinst, or install Sugar from the Fedora installer
without installing or ever running GNOME that workaround
will work for them as well.

Signed-off-by: Peter Robinson pbrobin...@fedoraproject.org
Signed-off-by: Simon Schampijer si...@laptop.org
---
 bin/sugar.in |   20 
 1 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/bin/sugar.in b/bin/sugar.in
index 12098db..df27143 100644
--- a/bin/sugar.in
+++ b/bin/sugar.in
@@ -62,6 +62,26 @@ export LANGUAGE=${LANGUAGE:-${LANG}}
 # Set Sugar's telepathy accounts directory
 export MC_ACCOUNT_DIR=$HOME/.sugar/$SUGAR_PROFILE/accounts
 
+# Check if the keyring exists and create a default
+# unencrypted keyring (OLPC #10290)
+keyring_path=$HOME/.gnome2/keyrings
+if [ ! -e $keyring_path/login.keyring ] 
+[ ! -e $keyring_path/default.keyring ]; then
+mkdir -p $keyring_path
+echo 'default'  $keyring_path/default
+TIME=$(/bin/date +%s)
+cat  $keyring_path/default.keyring.tmp EOF
+[keyring]
+display-name=default
+ctime=$TIME
+mtime=$TIME
+lock-on-idle=false
+lock-timeout=0
+EOF
+
+mv $keyring_path/default.keyring{.tmp,}
+fi
+
 # Workaround until gnome-keyring-daemon lets dbus activate it
 # https://bugzilla.gnome.org/show_bug.cgi?id=628302
 if test $SUGAR_EMULATOR = yes -a $(type gnome-keyring-daemon); then
-- 
1.7.7.6

___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


Re: [Sugar-devel] [PATCH] keyhandler: Use textual key names

2012-04-16 Thread Gary Martin
Hi Simon,

On 16 Apr 2012, at 09:46, Simon Schampijer wrote:

 On 03/28/2012 11:40 PM, Peter Robinson wrote:
 On Tue, Mar 27, 2012 at 9:22 PM, Daniel Draked...@laptop.org  wrote:
 Conversion of 0x## keycodes is broken in libegg with recent GDK.
 
 Switch to the textual names of the keys in question to work around this
 bug, reference:  https://bugzilla.gnome.org/show_bug.cgi?id=672950
 
 This fixes the frame key on XO laptops running Fedora 17.
 
 Signed-off-by: Daniel Draked...@laptop.org
 ---
  src/jarabe/view/keyhandler.py |4 ++--
  1 files changed, 2 insertions(+), 2 deletions(-)
 
 diff --git a/src/jarabe/view/keyhandler.py b/src/jarabe/view/keyhandler.py
 index a71f260..530da75 100644
 --- a/src/jarabe/view/keyhandler.py
 +++ b/src/jarabe/view/keyhandler.py
 @@ -51,11 +51,11 @@ _actions_table = {
 'XF86AudioRaiseVolume': 'volume_up',
 'altF11': 'volume_min',
 'altF12': 'volume_max',
 -'0x93': 'frame',
 +'XF86MenuKB': 'frame',
 'altTab': 'next_window',
 'altshiftTab': 'previous_window',
 'altEscape': 'close_window',
 -'0xDC': 'open_search',
 +'XF86WebCam': 'open_search',
  # the following are intended for emulator users
 'altshiftf': 'frame',
 'altshiftq': 'quit_emulator',
 
 I think we need a similar fix for the Fn key, I gett repeating = signs
 on a 1.75-HS and it doesn't work for pg-up dg-down on the XO-1/XO1.5
 membrane keyboard.
 
 Peter
 
 In os7 I can use fn+pg-up/pg-down fine (tested with membrane keyboard with a 
 XO-1.5). But there was one shortcut missing indeed in the conversion, the one 
 for the view source: 
 http://lists.sugarlabs.org/archive/sugar-devel/2012-April/036655.html

Not sure if this is related, but in 12.1.0 build 7 on an XO-1.75 with membrane 
keyboard, the Frame key and Journal search key are both non-functional (they 
work fine on a XO-1.75 HS keyboard).

Regards,
--Gary

 
 Thanks for productively noising,
   Simon
 ___
 Sugar-devel mailing list
 Sugar-devel@lists.sugarlabs.org
 http://lists.sugarlabs.org/listinfo/sugar-devel

___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


Re: [Sugar-devel] [PATCH] keyhandler: Use textual key names

2012-04-16 Thread Simon Schampijer

On 04/16/2012 02:23 PM, Gary Martin wrote:

Hi Simon,

On 16 Apr 2012, at 09:46, Simon Schampijer wrote:


On 03/28/2012 11:40 PM, Peter Robinson wrote:

On Tue, Mar 27, 2012 at 9:22 PM, Daniel Draked...@laptop.org   wrote:

Conversion of 0x## keycodes is broken in libegg with recent GDK.

Switch to the textual names of the keys in question to work around this
bug, reference:  https://bugzilla.gnome.org/show_bug.cgi?id=672950

This fixes the frame key on XO laptops running Fedora 17.

Signed-off-by: Daniel Draked...@laptop.org
---
  src/jarabe/view/keyhandler.py |4 ++--
  1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/jarabe/view/keyhandler.py b/src/jarabe/view/keyhandler.py
index a71f260..530da75 100644
--- a/src/jarabe/view/keyhandler.py
+++ b/src/jarabe/view/keyhandler.py
@@ -51,11 +51,11 @@ _actions_table = {
 'XF86AudioRaiseVolume': 'volume_up',
 'altF11': 'volume_min',
 'altF12': 'volume_max',
-'0x93': 'frame',
+'XF86MenuKB': 'frame',
 'altTab': 'next_window',
 'altshiftTab': 'previous_window',
 'altEscape': 'close_window',
-'0xDC': 'open_search',
+'XF86WebCam': 'open_search',
  # the following are intended for emulator users
 'altshiftf': 'frame',
 'altshiftq': 'quit_emulator',


I think we need a similar fix for the Fn key, I gett repeating = signs
on a 1.75-HS and it doesn't work for pg-up dg-down on the XO-1/XO1.5
membrane keyboard.

Peter


In os7 I can use fn+pg-up/pg-down fine (tested with membrane keyboard with a 
XO-1.5). But there was one shortcut missing indeed in the conversion, the one 
for the view source: 
http://lists.sugarlabs.org/archive/sugar-devel/2012-April/036655.html


Not sure if this is related, but in 12.1.0 build 7 on an XO-1.75 with membrane 
keyboard, the Frame key and Journal search key are both non-functional (they 
work fine on a XO-1.75 HS keyboard).

Regards,
--Gary


Right, this is fixed in master already, will be packaged and land in os8.

Regards,
   Simon
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


Re: [Sugar-devel] [PATCH sugar] Fix shortcut for view source

2012-04-16 Thread Sascha Silbe
Excerpts from Simon Schampijer's message of 2012-04-16 10:42:39 +0200:

[extensions/globalkey/viewsource.py]
 -BOUND_KEYS = ['0xEC', 'altshiftv']
 +BOUND_KEYS = ['XF86KbdLightOnOff', 'altshiftv']

Is Keyboard light on/off really a key that we want to trigger View
Source? Maybe it's what current OLPC images call the key, but that's
fixable.

If upstream (Linux) really is averse to adding a new definition for the
gear key, the following existing one [1] sounds like a better fit:

KEY_PROPS (Display the properties of the current document [2])


That key would be better mapped to opening the Journal details view (for
the current activity session), but if there's really push-back from the
input subsystem maintainers, it would be a reasonable compromise.

Sascha

[1] 
https://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=blob_plain;f=include/linux/input.h;hb=HEAD
[2] https://www.usb.org/developers/devclass_docs/Hut1_12v2.pdf (section 15.16)
-- 
http://sascha.silbe.org/
http://www.infra-silbe.de/


signature.asc
Description: PGP signature
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


[Sugar-devel] new-patch

2012-04-16 Thread Ariel Calzada

From b330bc11f58b82eaecbbd41224077da381e62408 Mon Sep 17 00:00:00 2001
From: Ariel Calzada ar...@acivitycentral.com
Date: Mon, 16 Apr 2012 11:02:19 -0500
Subject: [PATCH] =?UTF-8?q?Added=20decode=20utf-8=20and=20normalize=20string?=
 =?UTF-8?q?=20for=20fixing=20bug=20in=20nick=20that=20don't=20display=20well?=
 =?UTF-8?q?=20the=20nicknames=20that=20have=20accents=20like=20=C3=A1,=C3=A9?=
 =?UTF-8?q?,=C3=AD,=C3=B1?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 player.py |   18 ++
 1 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/player.py b/player.py
index 5e9e8db..a6636dc 100644
--- a/player.py
+++ b/player.py
@@ -8,17 +8,17 @@
 #
 # Copyright (C) 2007  Joshua Minor
 # This file is part of Maze.activity
-# 
+#
 # Maze.activity is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
 # the Free Software Foundation, either version 3 of the License, or
 # (at your option) any later version.
-# 
+#
 # Maze.activity is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
-# 
+#
 # You should have received a copy of the GNU General Public License
 # along with Maze.activity.  If not, see http://www.gnu.org/licenses/.
 
@@ -29,14 +29,16 @@ from sugar.graphics.xocolor import XoColor
 import pygame
 import re
 import os
+import unicodedata
 
 
 class Player:
 def __init__(self, buddy, shape='circle'):
 self.buddy = buddy
-self.nick = buddy.props.nick.decode(utf-8)
+name = buddy.props.nick.decode('utf-8')
+self.nick = unicodedata.normalize('NFC',name)
 colors = buddy.props.color.split(,)
-
+
 def string2Color(str):
 return (int(str[1:3], 16), int(str[3:5], 16), int(str[5:7], 16))
 self.colors = map(string2Color, colors)
@@ -70,7 +72,7 @@ class Player:
 self.position = (1, 1)
 self.previous = (1, 1)
 self.elapsed = None
-
+
 def animate(self, maze):
 # if the player finished the maze, then don't move
 if maze.map[self.position[0]][self.position[1]] == maze.GOAL:
@@ -83,7 +85,7 @@ class Player:
 else:
 self.direction = (0, 0)
 return self.position
-
+
 def move(self, direction, maze):
 Move the player in a given direction (deltax,deltay)
 newposition = (self.position[0] + direction[0], self.position[1] + 
direction[1])
@@ -111,7 +113,7 @@ class Player:
 directions.remove(d)
 # is there only one possible direction?
 if len(directions) == 1:
-   self.direction = directions[0]
+self.direction = directions[0]
 else:
 self.direction = (0, 0)
 
-- 
1.7.5.4

___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


Re: [Sugar-devel] new-patch

2012-04-16 Thread Anish Mangal
On Mon, Apr 16, 2012 at 21:37, Ariel Calzada ariel.calz...@gmail.com wrote:

 From b330bc11f58b82eaecbbd41224077da381e62408 Mon Sep 17 00:00:00 2001
 From: Ariel Calzada ar...@acivitycentral.com
 Date: Mon, 16 Apr 2012 11:02:19 -0500
 Subject: [PATCH] =?UTF-8?q?Added=20decode=20utf-8=20and=20normalize=20string?=
  =?UTF-8?q?=20for=20fixing=20bug=20in=20nick=20that=20don't=20display=20well?=
  =?UTF-8?q?=20the=20nicknames=20that=20have=20accents=20like=20=C3=A1,=C3=A9?=
  =?UTF-8?q?,=C3=AD,=C3=B1?=
 MIME-Version: 1.0
 Content-Type: text/plain; charset=UTF-8
 Content-Transfer-Encoding: 8bit


Please include a clear patch title stating clearly what the patch
does, and a detailed description of how it goes about doing it.

See [1][2] for good examples

 ---
  player.py |   18 ++
  1 files changed, 10 insertions(+), 8 deletions(-)

 diff --git a/player.py b/player.py
 index 5e9e8db..a6636dc 100644
 --- a/player.py
 +++ b/player.py
 @@ -8,17 +8,17 @@
  #
  # Copyright (C) 2007  Joshua Minor
  # This file is part of Maze.activity
 -#
 +#
  #     Maze.activity is free software: you can redistribute it and/or modify
  #     it under the terms of the GNU General Public License as published by
  #     the Free Software Foundation, either version 3 of the License, or
  #     (at your option) any later version.
 -#
 +#
  #     Maze.activity is distributed in the hope that it will be useful,
  #     but WITHOUT ANY WARRANTY; without even the implied warranty of
  #     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  #     GNU General Public License for more details.
 -#
 +#
  #     You should have received a copy of the GNU General Public License
  #     along with Maze.activity.  If not, see http://www.gnu.org/licenses/.

 @@ -29,14 +29,16 @@ from sugar.graphics.xocolor import XoColor
  import pygame
  import re
  import os
 +import unicodedata


Just wondering whether re, os and pygame, unicodedata should be 2
separate groups


  class Player:
     def __init__(self, buddy, shape='circle'):
         self.buddy = buddy
 -        self.nick = buddy.props.nick.decode(utf-8)
 +        name = buddy.props.nick.decode('utf-8')
 +        self.nick = unicodedata.normalize('NFC',name)

pep8: s/('NFC',name)/('NFC', name)

         colors = buddy.props.color.split(,)
 -
 +
         def string2Color(str):
             return (int(str[1:3], 16), int(str[3:5], 16), int(str[5:7], 16))
         self.colors = map(string2Color, colors)
 @@ -70,7 +72,7 @@ class Player:
         self.position = (1, 1)
         self.previous = (1, 1)
         self.elapsed = None
 -
 +
     def animate(self, maze):
         # if the player finished the maze, then don't move
         if maze.map[self.position[0]][self.position[1]] == maze.GOAL:
 @@ -83,7 +85,7 @@ class Player:
         else:
             self.direction = (0, 0)
         return self.position
 -
 +
     def move(self, direction, maze):
         Move the player in a given direction (deltax,deltay)
         newposition = (self.position[0] + direction[0], self.position[1] + 
 direction[1])
 @@ -111,7 +113,7 @@ class Player:
                 directions.remove(d)
         # is there only one possible direction?
         if len(directions) == 1:
 -                   self.direction = directions[0]
 +            self.direction = directions[0]
         else:
             self.direction = (0, 0)

 --
 1.7.5.4

 ___
 Sugar-devel mailing list
 Sugar-devel@lists.sugarlabs.org
 http://lists.sugarlabs.org/listinfo/sugar-devel


Reviewed-by: Anish Mangal an...@activitycentral.com

[1] https://patchwork.sugarlabs.org/patch/1257/
[2] https://patchwork.sugarlabs.org/patch/1348/
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


Re: [Sugar-devel] [PATCH Maze] Allow collaboration (SL #3296)

2012-04-16 Thread Rafael Ortiz
On Mon, Apr 16, 2012 at 10:07 AM, Manuel Kaufmann humi...@gmail.com wrote:

 Replaced get_buddy function by lookup_buddy as suggested the Error
 message.

 In this version is not allowed to play with more than one player in each XO
 (using the gamepad keywords). This is because a known issue [1] and we can
 not
 handle the child's nick properly.

 The mesh.PARTICIPANT_ADD event sends something like
 6be01ff2bcfaa58eeacc7f10a57b77b65470d...@jabber.sugarlabs.org in the
 buddy.prosp.nick variable and the mesh.broadcast send the correct
 child's
 name. So, when Maze creates the players uses the mesh.PARTICIPANT_ADD
 value and
 when it reads the messages it find the correct name (the name that the
 child
 chose)

 [1] http://dev.laptop.org/ticket/10750

 Signed-off-by: Manuel Kaufmann humi...@gmail.com
 ---
  game.py |   88
 +--
  1 file changed, 52 insertions(+), 36 deletions(-)

 diff --git a/game.py b/game.py
 index f710d92..b6319b1 100644
 --- a/game.py
 +++ b/game.py
 @@ -244,37 +244,44 @@ class MazeGame:
 self.mouse_in_use = 0

 elif event.type == mesh.CONNECT:
 -print Connected to the mesh.
 +log.debug(Connected to the mesh)
 elif event.type == mesh.PARTICIPANT_ADD:
 -buddy = mesh.get_buddy(event.handle)
 -if event.handle == mesh.my_handle():
 -print Me:, buddy.props.nick, buddy.props.color
 -else:
 -print Join:, buddy.props.nick, buddy.props.color
 -player = Player(buddy)
 -self.remoteplayers[event.handle] = player
 -self.allplayers.append(player)
 -self.allplayers.extend(player.bonusPlayers())
 -self.markPointDirty(player.position)
 -# send a test message to the new player
 -mesh.broadcast(Welcome %s % player.nick)
 -# tell them which maze we are playing, so they can sync up
 -mesh.send_to(event.handle, maze:%d,%d,%d,%d % \
 - (self.game_running_time(),
 -  self.maze.seed,
 -  self.maze.width, self.maze.height))
 -for player in self.localplayers:
 -if not player.hidden:
 -mesh.send_to(event.handle, move:%s,%d,%d,%d,%d
 % \
 - (player.nick,
 -  player.position[0],
 -  player.position[1],
 -  player.direction[0],
 -  player.direction[1]))
 +log.debug('mesh.PARTICIPANT_ADD')
 +
 +def withBuddy(buddy):
 +if event.handle == mesh.my_handle():
 +log.debug(Me: %s - %s, buddy.props.nick,
 +  buddy.props.color)
 +else:
 +log.debug(Join: %s - %s, buddy.props.nick,
 +  buddy.props.color)
 +player = Player(buddy)
 +self.remoteplayers[event.handle] = player
 +self.allplayers.append(player)
 +self.allplayers.extend(player.bonusPlayers())
 +self.markPointDirty(player.position)
 +# send a test message to the new player
 +mesh.broadcast(Welcome %s % player.nick)
 +# tell them which maze we are playing, so they can
 sync up
 +mesh.send_to(event.handle, maze:%d,%d,%d,%d % \
 + (self.game_running_time(),
 +  self.maze.seed,
 +  self.maze.width, self.maze.height))
 +for player in self.localplayers:
 +if not player.hidden:
 +mesh.send_to(event.handle,
 move:%s,%d,%d,%d,%d % \
 + (player.nick,
 +  player.position[0],
 +  player.position[1],
 +  player.direction[0],
 +  player.direction[1]))
 +
 +mesh.lookup_buddy(event.handle, callback=withBuddy)
 elif event.type == mesh.PARTICIPANT_REMOVE:
 +log.debug('mesh.PARTICIPANT_REMOVE')
 if event.handle in self.remoteplayers:
 player = self.remoteplayers[event.handle]
 -print Leave:, player.nick
 +log.debug(Leave: %s, player.nick)
 self.markPointDirty(player.position)
 self.allplayers.remove(player)
 for bonusplayer in player.bonusPlayers():
 @@ -283,9 +290,7 @@ class MazeGame:
 del 

Re: [Sugar-devel] [PATCH sugar-0.94] Don't treat SSID as UTF-8 character sequence (fixes SL#2023)

2012-04-16 Thread Sascha Silbe
Excerpts from Sascha Silbe's message of 2012-04-10 20:39:18 +0200:
 This is a backport of 7f8ba95a66780828531eba0494e004757bf45c71.
[...]
 This backport was not tested in any way.

Tested:
- filtering on ASCII and non-ASCII parts of the name of and connecting to:
  - an unsecured AP with a UTF-8 SSID (äöü߀sugartest, HostAP)
  - an unsecured AP with an ISO-8859-1 SSID (äöüßsugartest, HostAP)
  - an unsecured AP with a non-character SSID (0d:06:f0:0d, HostAP)
  - a WEP-secured AP with a UTF-8 name (äöü߀sugartest2, HostAP)
  - a WEP-secured AP with an ISO-8859-1 name (äöüßsugartest2, HostAP)
  - a WEP-secured AP with a non-character SSID (0d:06:f0:0d, HostAP)

In each case the name was displayed correctly in
a) the palette of the AP icon in the Neighbourhood,
b) the palette of the wireless network Frame device and
c) the title of the WLAN credentials (WEP/WPA passphrase) dialog (for
   the WEP cases).


As the non-character SSID test case has caused even Sugar 0.94 to
crash without this patch, I'm going to push the fix to sucrose-0.94.

Sascha

-- 
http://sascha.silbe.org/
http://www.infra-silbe.de/


signature.asc
Description: PGP signature
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


[Sugar-devel] [PATCH] This patch fix the bug, accent nicknames are not displayed well

2012-04-16 Thread Ariel Calzada
This patch is for fixing the bug in the display of nicknames with accents like 
áéíóúñ

---
 player.py |   18 ++
 1 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/player.py b/player.py
index 5e9e8db..a6636dc 100644
--- a/player.py
+++ b/player.py
@@ -8,17 +8,17 @@
 #
 # Copyright (C) 2007  Joshua Minor
 # This file is part of Maze.activity
-# 
+#
 # Maze.activity is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
 # the Free Software Foundation, either version 3 of the License, or
 # (at your option) any later version.
-# 
+#
 # Maze.activity is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
-# 
+#
 # You should have received a copy of the GNU General Public License
 # along with Maze.activity.  If not, see http://www.gnu.org/licenses/.
 
@@ -29,14 +29,16 @@ from sugar.graphics.xocolor import XoColor
 import pygame
 import re
 import os
+import unicodedata
 
 
 class Player:
 def __init__(self, buddy, shape='circle'):
 self.buddy = buddy
-self.nick = buddy.props.nick.decode(utf-8)
+name = buddy.props.nick.decode('utf-8')
+self.nick = unicodedata.normalize('NFC',name)
 colors = buddy.props.color.split(,)
-
+
 def string2Color(str):
 return (int(str[1:3], 16), int(str[3:5], 16), int(str[5:7], 16))
 self.colors = map(string2Color, colors)
@@ -70,7 +72,7 @@ class Player:
 self.position = (1, 1)
 self.previous = (1, 1)
 self.elapsed = None
-
+
 def animate(self, maze):
 # if the player finished the maze, then don't move
 if maze.map[self.position[0]][self.position[1]] == maze.GOAL:
@@ -83,7 +85,7 @@ class Player:
 else:
 self.direction = (0, 0)
 return self.position
-
+
 def move(self, direction, maze):
 Move the player in a given direction (deltax,deltay)
 newposition = (self.position[0] + direction[0], self.position[1] + 
direction[1])
@@ -111,7 +113,7 @@ class Player:
 directions.remove(d)
 # is there only one possible direction?
 if len(directions) == 1:
-   self.direction = directions[0]
+self.direction = directions[0]
 else:
 self.direction = (0, 0)
 
-- 
1.7.5.4

___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


[Sugar-devel] [PATCH] This patch fix the bug, accent nicknames are not displayed well

2012-04-16 Thread Ariel Calzada
This patch is for fixing the bug in the display of nicknames with accents like 
áéíóúñ
in maze activity

---
 player.py |   18 ++
 1 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/player.py b/player.py
index 5e9e8db..a6636dc 100644
--- a/player.py
+++ b/player.py
@@ -8,17 +8,17 @@
 #
 # Copyright (C) 2007  Joshua Minor
 # This file is part of Maze.activity
-# 
+#
 # Maze.activity is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
 # the Free Software Foundation, either version 3 of the License, or
 # (at your option) any later version.
-# 
+#
 # Maze.activity is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
-# 
+#
 # You should have received a copy of the GNU General Public License
 # along with Maze.activity.  If not, see http://www.gnu.org/licenses/.
 
@@ -29,14 +29,16 @@ from sugar.graphics.xocolor import XoColor
 import pygame
 import re
 import os
+import unicodedata
 
 
 class Player:
 def __init__(self, buddy, shape='circle'):
 self.buddy = buddy
-self.nick = buddy.props.nick.decode(utf-8)
+name = buddy.props.nick.decode('utf-8')
+self.nick = unicodedata.normalize('NFC',name)
 colors = buddy.props.color.split(,)
-
+
 def string2Color(str):
 return (int(str[1:3], 16), int(str[3:5], 16), int(str[5:7], 16))
 self.colors = map(string2Color, colors)
@@ -70,7 +72,7 @@ class Player:
 self.position = (1, 1)
 self.previous = (1, 1)
 self.elapsed = None
-
+
 def animate(self, maze):
 # if the player finished the maze, then don't move
 if maze.map[self.position[0]][self.position[1]] == maze.GOAL:
@@ -83,7 +85,7 @@ class Player:
 else:
 self.direction = (0, 0)
 return self.position
-
+
 def move(self, direction, maze):
 Move the player in a given direction (deltax,deltay)
 newposition = (self.position[0] + direction[0], self.position[1] + 
direction[1])
@@ -111,7 +113,7 @@ class Player:
 directions.remove(d)
 # is there only one possible direction?
 if len(directions) == 1:
-   self.direction = directions[0]
+self.direction = directions[0]
 else:
 self.direction = (0, 0)
 
-- 
1.7.5.4

___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


Re: [Sugar-devel] [PATCH] This patch fix the bug, accent nicknames are not displayed well

2012-04-16 Thread Rafael Ortiz
On Mon, Apr 16, 2012 at 2:13 PM, Ariel Calzada ariel.calz...@gmail.comwrote:

 This patch is for fixing the bug in the display of nicknames with accents
 like áéíóúñ
 in maze activity

 ---
  player.py |   18 ++
  1 files changed, 10 insertions(+), 8 deletions(-)

 diff --git a/player.py b/player.py
 index 5e9e8db..a6636dc 100644
 --- a/player.py
 +++ b/player.py
 @@ -8,17 +8,17 @@
  #
  # Copyright (C) 2007  Joshua Minor
  # This file is part of Maze.activity
 -#
 +#
  # Maze.activity is free software: you can redistribute it and/or
 modify
  # it under the terms of the GNU General Public License as published by
  # the Free Software Foundation, either version 3 of the License, or
  # (at your option) any later version.
 -#
 +#
  # Maze.activity is distributed in the hope that it will be useful,
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  # GNU General Public License for more details.
 -#
 +#
  # You should have received a copy of the GNU General Public License
  # along with Maze.activity.  If not, see 
 http://www.gnu.org/licenses/.

 @@ -29,14 +29,16 @@ from sugar.graphics.xocolor import XoColor
  import pygame
  import re
  import os
 +import unicodedata


  class Player:
 def __init__(self, buddy, shape='circle'):
 self.buddy = buddy
 -self.nick = buddy.props.nick.decode(utf-8)
 +name = buddy.props.nick.decode('utf-8')
 +self.nick = unicodedata.normalize('NFC',name)
 colors = buddy.props.color.split(,)
 -
 +
 def string2Color(str):
 return (int(str[1:3], 16), int(str[3:5], 16), int(str[5:7],
 16))
 self.colors = map(string2Color, colors)
 @@ -70,7 +72,7 @@ class Player:
 self.position = (1, 1)
 self.previous = (1, 1)
 self.elapsed = None
 -
 +
 def animate(self, maze):
 # if the player finished the maze, then don't move
 if maze.map[self.position[0]][self.position[1]] == maze.GOAL:
 @@ -83,7 +85,7 @@ class Player:
 else:
 self.direction = (0, 0)
 return self.position
 -
 +
 def move(self, direction, maze):
 Move the player in a given direction (deltax,deltay)
 newposition = (self.position[0] + direction[0], self.position[1] +
 direction[1])
 @@ -111,7 +113,7 @@ class Player:
 directions.remove(d)
 # is there only one possible direction?
 if len(directions) == 1:
 -   self.direction = directions[0]
 +self.direction = directions[0]
 else:
 self.direction = (0, 0)

 --
 1.7.5.4

 Thanks applied as:

http://git.sugarlabs.org/maze/mainline/commit/5f9ca2ed7e1143e23a86525dd1a1d1c86f604774

will be on v18.
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


Re: [Sugar-devel] [PATCH] Touchpad icon: update for upstream kernel API

2012-04-16 Thread Simon Schampijer

On 11/25/2011 09:10 PM, Daniel Drake wrote:

The HGPK pentablet selection code has gone upstream, but with a
different interface from the version included in previous OLPC kernels.
The interface is now:

echo -n pentablet  hgpk_mode

Port the touchpad icon to this new API.
Compatibility with the old non-upstream API has been dropped; I don't
anticipate users running this new sugar with an old kernel.

This fixes touchpad mode selection on kernels newer than 2.6.35.
---
  extensions/deviceicon/touchpad.py |   49 ++---
  1 files changed, 29 insertions(+), 20 deletions(-)

diff --git a/extensions/deviceicon/touchpad.py 
b/extensions/deviceicon/touchpad.py
index 6773afc..d6b4b37 100644
--- a/extensions/deviceicon/touchpad.py
+++ b/extensions/deviceicon/touchpad.py
@@ -31,19 +31,15 @@ from sugar.graphics import style

  from jarabe.frame.frameinvoker import FrameWidgetInvoker

-TOUCHPAD_MODE_CAPACITIVE = 'capacitive'
-TOUCHPAD_MODE_RESISTIVE = 'resistive'
-TOUCHPAD_MODES = [TOUCHPAD_MODE_CAPACITIVE, TOUCHPAD_MODE_RESISTIVE]
-STATUS_TEXT = {
-TOUCHPAD_MODE_CAPACITIVE: _('finger'),
-TOUCHPAD_MODE_RESISTIVE: _('stylus'),
-}
-STATUS_ICON = {
-TOUCHPAD_MODE_CAPACITIVE: 'touchpad-' + TOUCHPAD_MODE_CAPACITIVE,
-TOUCHPAD_MODE_RESISTIVE: 'touchpad-' + TOUCHPAD_MODE_RESISTIVE,
-}
+TOUCHPAD_MODE_MOUSE = 'mouse'
+TOUCHPAD_MODE_PENTABLET = 'pentablet'
+
+TOUCHPAD_MODES = (TOUCHPAD_MODE_MOUSE, TOUCHPAD_MODE_PENTABLET)
+STATUS_TEXT = (_('finger'), _('stylus'))
+STATUS_ICON = ('touchpad-capacitive', 'touchpad-resistive')
+
  # NODE_PATH is used to communicate with the touchpad device.
-NODE_PATH = '/sys/devices/platform/i8042/serio1/ptmode'
+NODE_PATH = '/sys/devices/platform/i8042/serio1/hgpk_mode'


  class DeviceView(TrayIcon):
@@ -105,7 +101,7 @@ class ResourcePalette(Palette):

  def toggle_mode(self):
   Toggle the touchpad mode. 
-self._mode = TOUCHPAD_MODES[1 - TOUCHPAD_MODES.index(self._mode)]
+self._mode = 1 - self._mode
  _write_touchpad_mode(self._mode)
  self._update()

@@ -115,24 +111,37 @@ def setup(tray):
  Frame. 
  if os.path.exists(NODE_PATH):
  tray.add_device(DeviceView())
-_write_touchpad_mode(TOUCHPAD_MODE_CAPACITIVE)
+_write_touchpad_mode_str(TOUCHPAD_MODE_MOUSE)


-def _read_touchpad_mode():
- Read the touchpad mode from the node path. 
+def _read_touchpad_mode_str():
+ Read the touchpad mode string from the node path. 
  node_file_handle = open(NODE_PATH, 'r')
-text = node_file_handle.read()
+text = node_file_handle.read().strip().lower()
  node_file_handle.close()
+return text
+

-return TOUCHPAD_MODES[int(text[0])]
+def _read_touchpad_mode():
+ Read the touchpad mode and return the mode indice. 
+mode_str = _read_touchpad_mode_str()
+if not mode_str in TOUCHPAD_MODES:
+return None
+return TOUCHPAD_MODES.index(mode_str)


-def _write_touchpad_mode(touchpad):
+def _write_touchpad_mode_str(mode_str):
   Write the touchpad mode to the node path. 
  try:
  node_file_handle = open(NODE_PATH, 'w')
  except IOError, e:
  logging.error('Error opening %s for writing: %s', NODE_PATH, e)
  return
-node_file_handle.write(str(TOUCHPAD_MODES.index(touchpad)))
+node_file_handle.write(mode_str)
  node_file_handle.close()
+
+
+def _write_touchpad_mode(mode_num):
+ Look up the mode (by indice) and write to node path. 
+return _write_touchpad_mode_str(TOUCHPAD_MODES[mode_num])
+


This patch is needed now for latest kernel on the XO-1. Tested on the 
latest 12.1.0 builds.


Please push,
   Simon
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


Re: [Sugar-devel] [PATCH] Touchpad icon: update for upstream kernel API

2012-04-16 Thread Daniel Drake
On Mon, Apr 16, 2012 at 1:48 PM, Simon Schampijer si...@schampijer.de wrote:
 This patch is needed now for latest kernel on the XO-1. Tested on the latest
 12.1.0 builds.

OK, pushed with the changes noted earlier in the thread.
Happy to act on the rest of Sascha's feeback if it solidifies.

cheers
Daniel
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


[Sugar-devel] [ASLO] Release Read-99

2012-04-16 Thread Sugar Labs Activities
Activity Homepage:
http://activities.sugarlabs.org/addon/4028

Sugar Platform:
0.96 - 0.96

Download Now:
http://activities.sugarlabs.org/downloads/file/27974/read-99.xo

Release notes:
Initialize current page and number of pages in the toolbar - SL #3434
Updated pt translation


Sugar Labs Activities
http://activities.sugarlabs.org

___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


Re: [Sugar-devel] [PATCH] Touchpad icon: update for upstream kernel API

2012-04-16 Thread Frederick Grose
On Mon, Apr 16, 2012 at 4:06 PM, Daniel Drake d...@laptop.org wrote:

 On Mon, Apr 16, 2012 at 1:48 PM, Simon Schampijer si...@schampijer.de
 wrote:
  This patch is needed now for latest kernel on the XO-1. Tested on the
 latest
  12.1.0 builds.

 OK, pushed with the changes noted earlier in the thread.
 Happy to act on the rest of Sascha's feeback if it solidifies.

 cheers
 Daniel


There is also a Sugar themed icon, which Benzea has approved, available for
this.
https://bugs.sugarlabs.org/ticket/2950

   --Fred
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


[Sugar-devel] [PATCH] Prevent handling network devices twice (OLPC#11782)

2012-04-16 Thread Daniel Drake
Due to the asynchronous way that dbus works, it is possible to
receive a network device listed in the initial GetDevices call,
and as a DeviceAdded signal, if the device appears during Sugar
initialisation.

Check to see that a device is really new before processing it.
Fixes a case seen by Manuel and me where two network device
icons appear.

Signed-off-by: Daniel Drake d...@laptop.org
---
 extensions/deviceicon/network.py |3 +++
 src/jarabe/desktop/meshbox.py|5 +
 2 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/extensions/deviceicon/network.py b/extensions/deviceicon/network.py
index 09a3abb..96713fb 100644
--- a/extensions/deviceicon/network.py
+++ b/extensions/deviceicon/network.py
@@ -1020,6 +1020,9 @@ class NetworkManagerObserver(object):
 logging.error('Failed to get devices: %s', err)
 
 def _check_device(self, device_op):
+if device_op in self._devices:
+return
+
 nm_device = self._bus.get_object(network.NM_SERVICE, device_op)
 props = dbus.Interface(nm_device, dbus.PROPERTIES_IFACE)
 
diff --git a/src/jarabe/desktop/meshbox.py b/src/jarabe/desktop/meshbox.py
index 0d0c9c1..20dc413 100644
--- a/src/jarabe/desktop/meshbox.py
+++ b/src/jarabe/desktop/meshbox.py
@@ -350,6 +350,8 @@ class NetworkManagerObserver(object):
 
 device_type = props.Get(network.NM_DEVICE_IFACE, 'DeviceType')
 if device_type == network.NM_DEVICE_TYPE_WIFI:
+if device_o in self._devices:
+return
 self._devices[device_o] = DeviceObserver(device)
 self._devices[device_o].connect('access-point-added',
 self.__ap_added_cb)
@@ -358,6 +360,8 @@ class NetworkManagerObserver(object):
 if self._have_adhoc_networks:
 self._box.add_adhoc_networks(device)
 elif device_type == network.NM_DEVICE_TYPE_OLPC_MESH:
+if device_o == self._olpc_mesh_device_o:
+return
 self._olpc_mesh_device_o = device_o
 self._box.enable_olpc_mesh(device)
 
@@ -378,6 +382,7 @@ class NetworkManagerObserver(object):
 
 if self._olpc_mesh_device_o == device_o:
 self._box.disable_olpc_mesh(device_o)
+self._olpc_mesh_device_o = None
 
 def __ap_added_cb(self, device_observer, access_point):
 self._box.add_access_point(device_observer.device, access_point)
-- 
1.7.7.6

___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


[Sugar-devel] [ASLO] Release Maze-18

2012-04-16 Thread Sugar Labs Activities
Activity Homepage:
http://activities.sugarlabs.org/addon/4071

Sugar Platform:
0.82 - 0.96

Download Now:
http://activities.sugarlabs.org/downloads/file/27975/maze-18.xo

Release notes:



Sugar Labs Activities
http://activities.sugarlabs.org

___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


Re: [Sugar-devel] [ASLO] Release Maze-18

2012-04-16 Thread Rafael Ortiz
On Mon, Apr 16, 2012 at 9:41 PM, Sugar Labs Activities 
activit...@sugarlabs.org wrote:

 Activity Homepage:
 http://activities.sugarlabs.org/addon/4071

 Sugar Platform:
 0.82 - 0.96

 Download Now:
 http://activities.sugarlabs.org/downloads/file/27975/maze-18.xo

 Release notes:




*Allow collaboration (SL #3296), Manuel Kaufmann humi...@gmail.com,
*pep8 fix Rafael Ortiz raf...@activitycentral.com
* Fix the bug, accent nicknames are not displayed well Ariel Calzada
ar...@activitycentral.com
* New translations.



 Sugar Labs Activities
 http://activities.sugarlabs.org

 ___
 Sugar-devel mailing list
 Sugar-devel@lists.sugarlabs.org
 http://lists.sugarlabs.org/listinfo/sugar-devel

___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


[Sugar-devel] [PATCH Maze] Collaboration: allow multiple users in the same XO

2012-04-16 Thread Manuel Kaufmann
This is a workaround to the problem with the real nick on a jabber server[1].
Now, we are using the unique identifier (mesh.my_handle or event.handle) for
each player in the game plus a -%d at the end of the uid. This value
(Player.uid) is added only when the Activity is shared otherwise this
field is None.

This new workaround allow to distinguish between many users (up to 3) for each
XO laptop -using the gamepad keys.

[1] http://dev.laptop.org/ticket/10750

Signed-off-by: Manuel Kaufmann humi...@gmail.com
---
 game.py   |   27 ---
 player.py |   24 ++--
 2 files changed, 34 insertions(+), 17 deletions(-)

diff --git a/game.py b/game.py
index b6319b1..85f6d7f 100644
--- a/game.py
+++ b/game.py
@@ -33,7 +33,9 @@ import pygame
 import olpcgames
 
 import logging
+logging.basicConfig()
 log = logging.getLogger('Maze')
+log.setLevel(logging.DEBUG)
 
 import olpcgames.pausescreen as pausescreen
 import olpcgames.mesh as mesh
@@ -195,7 +197,7 @@ class MazeGame:
 
 if len(self.remoteplayers)  0:
 mesh.broadcast(move:%s,%d,%d,%d,%d % \
-   (player.nick,
+   (player.uid,
 player.position[0],
 player.position[1],
 player.direction[0],
@@ -245,6 +247,7 @@ class MazeGame:
 
 elif event.type == mesh.CONNECT:
 log.debug(Connected to the mesh)
+
 elif event.type == mesh.PARTICIPANT_ADD:
 log.debug('mesh.PARTICIPANT_ADD')
 
@@ -252,10 +255,19 @@ class MazeGame:
 if event.handle == mesh.my_handle():
 log.debug(Me: %s - %s, buddy.props.nick,
   buddy.props.color)
+# README: this is a workaround to use an unique
+# identifier instead the nick of the buddy
+# http://dev.laptop.org/ticket/10750
+count = ''
+for i, player in enumerate(self.localplayers):
+if i  0:
+count = '-%d' % i
+player.uid = mesh.my_handle() + count
 else:
 log.debug(Join: %s - %s, buddy.props.nick,
   buddy.props.color)
 player = Player(buddy)
+player.uid = event.handle
 self.remoteplayers[event.handle] = player
 self.allplayers.append(player)
 self.allplayers.extend(player.bonusPlayers())
@@ -269,8 +281,9 @@ class MazeGame:
   self.maze.width, self.maze.height))
 for player in self.localplayers:
 if not player.hidden:
-mesh.send_to(event.handle, move:%s,%d,%d,%d,%d % 
\
- (player.nick,
+mesh.send_to(event.handle,
+ move:%s,%d,%d,%d,%d % \
+ (player.uid,
   player.position[0],
   player.position[1],
   player.direction[0],
@@ -367,7 +380,7 @@ class MazeGame:
 return
 if message.startswith(move:):
 # a player has moved
-nick, x, y, dx, dy = message[5:].split(,)[:5]
+uid, x, y, dx, dy = message[5:].split(,)[:5]
 
 # README: this function (player.bonusPlayer) sometimes
 # returns None and the activity doesn't move the players.
@@ -377,7 +390,7 @@ class MazeGame:
 # So, we have set remote users with this kind of name but
 # we receive the reald child's name in the mesh message
 
-# player = player.bonusPlayer(nick)
+player = player.bonusPlayer(uid)
 player.hidden = False
 
 self.markPointDirty(player.position)
@@ -400,8 +413,8 @@ class MazeGame:
 self.reset()
 elif message.startswith(finish:):
 # someone finished the maze
-nick, elapsed = message[7:].split(,)[:2]
-player = player.bonusPlayer(nick)
+uid, elapsed = message[7:].split(,)[:2]
+player = player.bonusPlayer(uid)
 player.elapsed = float(elapsed)
 self.markPointDirty(player.position)
 else:
diff --git a/player.py b/player.py
index a6636dc..ee2df37 100644
--- a/player.py
+++ b/player.py
@@ -22,15 +22,12 @@
 # You should have received a copy of the GNU General Public License
 # along with Maze.activity.  If not, see http://www.gnu.org/licenses/.
 
-from olpcgames.util import get_bundle_path
-bundlepath = get_bundle_path()
-from sugar.graphics.icon import Icon
-from 

Re: [Sugar-devel] [PATCH Maze] Collaboration: allow multiple users in the same XO

2012-04-16 Thread Manuel Kaufmann
On Tue, Apr 17, 2012 at 00:24, Manuel Kaufmann humi...@gmail.com wrote:
 This new workaround allow to distinguish between many users (up to 3) for each
 XO laptop -using the gamepad keys.

I just tested it with only one XO and a Sugar JHBuild instance because
I have got just one XO. Please, if you have more than one, test it
with more than 4 players.

Another comment: I'm not sure about the way that I solved this, I
think it need a kind of revision before to be applied, but I think
this is a good start for discussion.

Let me know anything you want please.

See you,

-- 
Kaufmann Manuel
Blog: http://humitos.wordpress.com/
Porfolio: http://fotos.mkaufmann.com.ar/
PyAr: http://www.python.com.ar/
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel