Merge branch 'master' of git+ssh://dev.laptop.org/git/sugar

This commit is contained in:
Marco Pesenti Gritti 2007-09-25 20:20:33 +02:00
commit a449430500
4 changed files with 84 additions and 7 deletions

4
NEWS
View File

@ -1,3 +1,7 @@
* #948 Accept ascii passphrases for WEP networks. '$:1a2b3c4d' for hex keys,
's:my passphrase' for 5 or 13 characters ascii passphrases, or just the plain
key for ascii passphrases of any other length. (tomeu)
* #2477 Support dbus introspection in sugar-native-factory (bertf)
* #2674 Add arrows to hint about the frame corner activation (marco)
* #2665 Re-arrange device icons in a line at the bottom (marco)
* #3378 Support changes in activity scope (incomplete!) (smcv, marco)

View File

@ -137,6 +137,40 @@ create_instance(int argc)
/* handle dbus Introspect() call */
static DBusHandlerResult
handle_introspect(DBusConnection *connection, DBusMessage* message)
{
DBusMessage *reply;
const char *introspect_xml =
DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE
"<node>\n"
" <interface name=\"org.freedesktop.DBus.Introspectable\">\n"
" <method name=\"Introspect\">\n"
" <arg direction=\"out\" type=\"s\" />\n"
" </method>\n"
" </interface>\n"
" <interface name=\"org.laptop.ActivityFactory\">\n"
" <method name=\"create\">\n"
" <arg direction=\"in\" type=\"a{ss}\" />\n"
" </method>\n"
" </interface>\n"
"</node>\n";
reply = dbus_message_new_method_return(message);
dbus_message_append_args(reply,
DBUS_TYPE_STRING, &introspect_xml,
DBUS_TYPE_INVALID);
dbus_connection_send(connection, reply, NULL);
dbus_message_unref(reply);
return DBUS_HANDLER_RESULT_HANDLED;
}
/* handle dbus create() call */
static DBusHandlerResult
@ -212,8 +246,12 @@ factory_message_func(DBusConnection *connection,
void *user_data)
{
if (dbus_message_is_method_call(message,
"org.laptop.ActivityFactory",
"create"))
"org.freedesktop.DBus.Introspectable",
"Introspect"))
return handle_introspect(connection, message);
else if (dbus_message_is_method_call(message,
"org.laptop.ActivityFactory",
"create"))
return handle_create(connection, message);
else
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;

View File

@ -16,7 +16,9 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
import md5
from gettext import gettext as _
import gobject, gtk
IW_AUTH_ALG_OPEN_SYSTEM = 0x00000001
@ -55,6 +57,29 @@ def string_is_hex(key):
is_hex = False
return is_hex
def string_is_ascii(string):
try:
string.encode('ascii')
return True
except:
return False
def string_to_hex(passphrase):
key = ''
for c in passphrase:
key += hex(ord(c))[2:]
return key
def hash_passphrase(passphrase):
# passphrase must have a length of 64
if len(passphrase) > 64:
passphrase = passphrase[:64]
elif len(passphrase) < 64:
while len(passphrase) < 64:
passphrase += passphrase[:64 - len(passphrase)]
passphrase = md5.new(passphrase).digest()
return string_to_hex(passphrase)[:26]
class KeyDialog(gtk.Dialog):
def __init__(self, net, async_cb, async_err_cb):
gtk.Dialog.__init__(self, flags=gtk.DIALOG_MODAL)
@ -73,6 +98,7 @@ class KeyDialog(gtk.Dialog):
self._entry = gtk.Entry()
#self._entry.props.visibility = False
self._entry.connect('changed', self._update_response_sensitivity)
self._entry.connect('activate', self._entry_activate_cb)
self.vbox.pack_start(self._entry)
self.vbox.set_spacing(6)
self.vbox.show_all()
@ -86,6 +112,9 @@ class KeyDialog(gtk.Dialog):
self._entry.grab_focus()
self.set_has_separator(True)
def _entry_activate_cb(self, entry):
self.response(gtk.RESPONSE_OK)
def create_security(self):
raise NotImplementedError
@ -119,6 +148,13 @@ class WEPKeyDialog(KeyDialog):
def create_security(self):
key = self._entry.get_text()
if key.startswith('$:'):
key = key[2:]
elif key.startswith('s:') and ((len(key) - 2) in [5, 13]):
key = string_to_hex(key[2:])
else:
key = hash_passphrase(key)
it = self.combo.get_active_iter()
(auth_alg, ) = self.store.get(it, 1)
@ -132,10 +168,9 @@ class WEPKeyDialog(KeyDialog):
return Security.new_from_args(we_cipher, (key, auth_alg))
def _update_response_sensitivity(self, ignored=None):
key = self._entry.get_text()
is_hex = string_is_hex(key)
valid_len = (len(key) == 10 or len(key) == 26)
self.set_response_sensitive(gtk.RESPONSE_OK, is_hex and valid_len)
# As the md5 passphrase can be of any length and has no indicator, we
# cannot check for the validity of the input.
self.set_response_sensitive(gtk.RESPONSE_OK, True)
class WPAKeyDialog(KeyDialog):
def __init__(self, net, async_cb, async_err_cb):

View File

@ -506,7 +506,7 @@ class NMInfo(object):
self._key_dialog = None
widget.destroy()
if response_id == gtk.RESPONSE_CANCEL:
if response_id in [gtk.RESPONSE_CANCEL, gtk.RESPONSE_NONE]:
# key dialog dialog was canceled; send the error back to NM
async_err_cb(CanceledKeyRequestError())
elif response_id == gtk.RESPONSE_OK: